
127B Section 24- or 25-Jan 2008
In today's section you are asked to
•Implement a class and its unit test in Eclipse using JUnit.
•Set up Eclipse to submit your Eclipse Project to WebCat from one of our lab machines.
oYou will need to read your email to get your WebCat user name and password
oYou should have received this sometime late Wednesday night
•Submit your Eclipse project to WebCat using the Submit option
oDo this 15 minutes before your section ends even if your code is wrong
You can resubmit
oIf you do not get 100% during section, submit by Monday 12:45 pm (not a second later) for
the 3pts (0-32% is 0 pts, 33-65% is 1 pt, 66%-90% is 2pts, > 90% is 3pts)
oNote: The Submit option is available in the lab, but you will need to add this plugin on your
home machine (instructions appear under the WebCat link from our home page).
1. Implement class PiggyBank
oStart Eclipse and create a project named PiggyBank
oImplement class PiggyBank, an object to which pennies, nickels and dimes can be
added. Each PiggyBank object keeps track of how much money is in the PiggyBank. A
PiggyBank can be raided anytime to reduce the total amount of money to 0.00. Make
sure you include a unit test PiggyBankTest that tests all methods. Also make sure the
unit test name ends with Test. Do not name it TestPiggyBank (or you will get 0%) The
PiggyBank class must have the following methods:
/**
* Construct a PiggyBank with no money.
*/
public PiggyBank()
/**
* Return the amount of money in this PiggyBank as a dollars and cents
* amount. After construction or a smash, getTotal() must return 0.0.
*/
public double getTotal()
/**
* Add the given number of pennies to this PiggyBank.
* @param penniesToAdd The number of pennies added to this PiggyBank.
*/
public void addPennies(int penniesToAdd) {
total += penniesToAdd;
}
/**
* Add the given number of nickels this PiggyBank.
* @param nickelsToAdd The number of nickels to add to this PiggyBank.
*/
public void addNickels(int nickelsToAdd)