CS 110 Fundamentals of Computing
Homework Assignment 7
Bolker and Rodriguez
Spring 2004

Due date: Thursday, April 1, when labs close.

Testing is an important part of the software development process. So everything you write must be tested and you must write about your testing in your memo, even if the exercise does not explicitly ask for it.

  1. JOI Exercise 5-5 (Refactoring the Shapes classes). This exercise has very little new code. Your job is to move code that's already written to the right places. Here's your chance to become a whiz at cut and paste from one emacs buffer to another.

    Start with the code in www.cs.umb.edu/joi/latest-joi-cd/joi/5/shapes/, www.cs.umb.edu/~eb/110/hw4/solution/Frame.java and www.cs.umb.edu/joi/latest-joi-cd/joi/3/shapes/Box.java. You will have to write your own Rectangle.java. You won't have to look at Screen.java but you will have to have it to compile. You can ignore ShapeOnScreen.java - it's there only for Exercise 5-7, which is optional.

    Be sure to make these changes in small steps:

    	while there is more work to do
    	    move a little bit of code (perhaps one field or method)
    	    compile
    	    test to see that behavior hasn't changed
    
    If you try to speed things up by doing a lot at once you will surely spend much more time in the long run.

  2. JOI Exercise 5-20 (Savings accounts). Directory bank contains the files you'll need to start your work, including a stub declaration for class SavingsAccount. The Bank class there will soon incorporate a solution to part of hw6.

    Hard code the interest rate at 5% and the fee per transaction when there are more than three transactions in a month at $1. Do not try to get these values from the Bank (as the Exercise suggests you should.)

  3. Optional. Exercise 5-7 (Shape application upgrade.) This is very long. It's in the book, but we've never assigned it before. You need not do it all. Be sure to test and write about any parts of it you do. You might want to work with Java 1.5, since there's lots of collection code to be written.
From: Ethan Bolker 
Subject: ex. 5-20
Date: Wed, 31 Mar 2004 20:04:18 -0500 (EST)


 > From: a classmate
 > To: eb@cs.umb.edu
 > Subject: ex. 5-20
 > Date: Wed, 31 Mar 2004 17:38:46 -0500
 > 
 > should we make a getter for SavingsAccount's field that stores the
 > # of remaining free transactions? If so, I'm assuming a way to use
 > this should be put into Bank's customer transactions.

Do not change the API for any class. 

Do not rely on changes in Bank to make your SavingsAccount work. We
will use our Bank and won't even look at yours.

----------------------------------------------------------------------

 > From: a classmate
 > To: eb@cs.umb.edu
 > Subject: bank testing
 > Date: Wed, 31 Mar 2004 17:43:07 -0500
 > 
 > when i was testing out SavingsAccount, i tried giving it a "cash check" command for fun. Bank crashed with:
 >     transaction: ca
 >     amount of check: 4
 > java.lang.ClassCastException
 > 	at Bank.processTransactionsForAccount(Bank.java:168)
 > 	at Bank.visit(Bank.java:99)
 > 	at Bank.main(Bank.java:383)
 > Exception in thread "main" 
 > 
 > should i fix this, or just leave it alone since it's not really
 > part of the exercises?

Don't try to fix anything. We will learn how to handle errors in
Chapter 7.

----------------------------------------------------------------------

 > From: a classmate
 > To: eb@cs.umb.edu
 > Subject: a qustion about turn in hw7
 > Date: Wed, 31 Mar 2004 23:13:33 +0000
 > 
 > Prof. Bolker,
 > 
 > Is that we only need to turn in SavingsAccount.java rather than all the 
 > SubClass of BankAccount.java and Bank.java?

See the answer to the first question in this email. We will look only
at your SavingsAccount.java. It must work with all the rest of our
classes.

From: Ethan Bolker 
To: rmenard@cs.umb.edu
Subject: turning in too much in the Bank exercise
Date: Wed, 31 Mar 2004 20:08:09 -0500 (EST)

When compiling and testing SavingsAccount be sure to use all our other
class files, not ones compiled from source submitted by the
students. In fact, take off a few points if people submit more than
SavingsAccount.java for this problem.

If people have already submitted extra files when they read this email
they can effectively erase them by turning in empty files with the
same names as the ones they shouldn't have turned in in the first
place.