Assignment 7
Goals: Learn to program with mutation and resolve circularity in data.
Instructions
The names of the projects and some of the project files must be exactly the same as specified in the assignment. Failure to do so makes it impossible for the graders to run your submission and results in immediate loss of at least 50% of the homework credit.
Make sure you follow the style guidelines for code indentation.
You will submit this assignment by the deadline using the Web-CAT submission system.
With each homework you will also submit your log file named pairxxx.txt where you replace xxx with your pair number.
On top of every file you submit you will have the names of both partners, and the pair number.
The .txt file will be the log of your work on this assignment. Each log entry will have data and time, who was present (one or both of the partners) and a short comment decribing what you were working on.
Due Date: Thursday, February 28th, 12:00 midnight.
Practice Problems
Work out these problems on your own. Save them in an electronic portfolio, so you can show them to your instructor, review them before the exam, use them as a reference when working on the homework assignments.
Review the lecture notes on Books and Authors with circularly referential data and actually run the programs.
Add new examples of books, define the method that checks whether two books are the same.
Problem 1
Finish all work in the Lab 7a and hand it in.
Specifically:
Design the method addBuddy and then make example of the circle of buddies as given in the lab.
Design the method hasDirectBuddy
Design the method countCommonBuddies
Design the method hasDistantBuddy
Design the method partyCount that counts the number of people who will be invited to a party given by this person if all buddies and all buddies of all buddies (including the distant ones) come to the party.
Submission for Problem 1:
The instructor’s test program will assume that you have made examples of all people listed and the object that represents each person has the same name as that person, but in all lower-case letters.
So, you should define ann, bob, etc.
The instructor’s test program assumes that the headers of all methods are the same as given in the lab document.
If you cannot design these methods, include at least the method header and a stub code within that produces some value of the expected type. So, for example, if the method produces a boolean value, just write return true;, if it produces a String, write return "s";, etc. This will make your program compile and will run all instructor’s tests, even though they will probably fail.
What will be tested on submission:
Name your examples clas for Problem 1 ExamplesBuddies.
You must have a method void initBuddies() is the ExamplesBuddies class that initializes all person’s buddy lists. Make sure the method can be called repeatedly.
The test program will test the methods hasDirectBuddy, hasDistantBuddy, countCommonBuddies, and partyCount.
Make sure you have at least the stubs for these methods defined in the appropriate classes and interfaces.
Make sure the ExamplesBuddies class is defined in its own file named ExamplesBuddies.java
Problem 2
Finish all work in the Lab 7b and hand it in.
Specifically:
Make examples of Checking, Savings, and Credit accounts. including the check1 and savings1 examples that were included in the lab code.
Design the method withdraw for all accounts.
Design the method deposit for all accounts.
Design the method openAccount that allows the customer to open a new account in the bank.
For the class Bank design the method deposit as described in Lab 7b
For the class Bank design the method withdraw as described in Lab 7b
For the class Bank design the method removeAccount as described in Lab 7b
Submission for Problem 2:
The instructor’s test program will assume that you have not modified the examples given in the lab code and that your method headers are as given in the lab document.
The instructor’s test program assumes that the headers of all methods are the same as given in the lab document.
If you cannot design these methods, include at least the method header and a stub code within that produces some value of the expected type. So, for example, if the method produces a boolean value, just write return true;, if it produces a String, write return "s";, etc. This will make your program compile and will run all instructor’s tests, even though they will probably fail.