jpa04 : ArrayList, Sorting, Comparators, Lambdas

num ready? description assigned MW lect due MW lect assigned TR lect due TR lect
jpa04 true ArrayList, Sorting, Comparators, Lambdas Mon 11/02 05:00PM Mon 11/09 11:00PM

This assignment is jpa04, i.e “Java Programming Assignment 04”.

If you find typos or problems with the lab instructions, please report them on the #typos channel on Slack

In this lab:

Preparation

Before starting this lab, you should understand how to use the built-in methods for sorting in Java, which rely on an understanding of:

These concepts are covered in these online exercises and videos:

Working in a pair?

You have the option to work in a pair on this assignment.

To set up a pair repo, see these instructions: Pair Repo Setup.

In addition:

If you are in your repo directory, and type git log at the command line, you’ll see a list of the commits for your repo.

Record that you are pairing on each commit message by putting the initials of the pair partners at the start of the commit message.

E.g. If Selena Gomez is driving, and Justin Timberlake is navigating, and you fixed a bug in your getDanceMoves() method, your commit message should be SG/JT fixed bug in getDanceMoves()

We should see frequent switches between SG/JT and JT/SG.

When remote pairing, this means switching who is sharing their screen:

Step-by-Step

Step 0: Set up your repo

When cloning your repo, be sure to use only the ssh links.

You may work individually or as a pair on this lab. However, if you work as a pair, please:

The starter code is in https://github.com/ucsb-cs156-f20/STARTER-jpa04. Visit that page for the approrpiate URL to add the starter remote.

To add the starter as a remote, cd into the repo you cloned, then do:

git remote add starter https://github.com/ucsb-cs156-f20/STARTER-jpa04

Then do:

git checkout -b main
git pull starter main
git push origin main

That should get you set up with the starter code.

Step 1: Copy code from your jpa01 submission.

This lab builds on your jpa01 submission. In jpa01, there were two classes in the starter code, both inside the package edu.ucsb.cs56.pconrad.menuitems:

Class Name File Name
MenuItem src/main/java/edu/ucsb/cs56/pconrad/menuitems/MenuItem.java
MenuItemTest src/test/java/edu/ucsb/cs56/pconrad/menuitems/MenuItemTest.java

Your starter code for jpa04 contains these same two files, but the “original” versions from the jpa01 starter. You should copy your code for both MenuItem.java and MenuItemTest.java from your jpa01 directory into the corresponding file in your new jpa04 directory.

Note that there are also new classes Menu.java and MenuTest.java. Leave these alone for now; you’ll be modfiying those as part of this programming assignment.

Commit the change to the files MenuItem.java and MenuItemTest.java. As you commit the change, consider the information below about good commit messages.

Write a good commit message

As you commit the change, start now with the habit writing meaningful commit messages. Starting from this assignment, you may be occasionally graded on a random sample of your commit messages, with the initial rubric consisting of these parts:

A good commit message in this case would be something like this, where xy are your initials:

git commit -m "xy - replace MenuItem and MenuItemTest classes with solutions from jpa01"

Reminder of Maven Commands

Here is a reminder about the commands you’ll need as you work with the code. Try them out now.

To do this Type this command Notes
compile the code mvn compile  
reset everything mvn clean  
run the tests mvn test  
generate a report of test coverage mvn test jacoco:report Open the file target/site/jacoco/index.html in a browser to read the report
generate a jar file mvn package  
generate a mutation test report mvn test org.pitest:pitest-maven:mutationCoverage Open the file target/pit-reports/yyyymmddhhmm/index.html to see the report; note that yyyymmddhhmm will be replaced by a date/timestamp.

Step 3: Look at the code for the Menu.java and MenuTest.java

There are two new classes in the jpa04 code; they live in the same package as MenuItem.java and MenuItemTest.java:

Your job in this lab is to:

In addition, there are a few additional instructor test cases for the MenuItem.java class that might catch bugs that the test suite for jpa01 missed. So if your code has those bugs, you may need to do some additional work in the MenuItem.java class as well.

Methods you need to implement in Menu:

Checking the tests

To check the code against the tests that you’ve written, use:

To check your test coverage, use:

When you see that you are passing all of your own tests and killing off all the mutants, you can try submitting to Gradescope. The grade breakdown is:

Do I need to adjust the CODECOV_TOKEN?

For this lab, we are not checking that you’ve fixed the CODECOV_TOKEN.

You are encouraged to set that up, as it’s good practice for future assignments, but it is not a requirement in terms of your grade.

End of description for jpa04