Assignment 5: Designing constructors; Understanding equality
Goals: Learn to design constructors that assure the integrity of data and provide convenience for the user. Explore the complexity of defining equality of two objects in a union.
1 Instructions
The names of the classes must be exactly the same as specified. The same is the case for the names and types of the fields within the class, as well as the order in which they are defined and listed as the constructor arguments. This allows us to design our own Examples class that tests your program.
Make sure you follow the style guidelines that WebCAT enforces. For now the most important ones are: using spaces instead of tabs, indenting by 4 characters, following the naming conventions (data type names start with a capital letter, names of fields and methods start with a lower case letter), and having spaces before curly braces.
You will submit this assignment by the deadline using the Web-CAT submission system. You may submit as many times as you wish. Be aware of the fact that close to the deadline the WebCAT system may slow down to handle many submissions - so try to finish early.
With each homework you will also submit your log file named pair-user1-user2.txt where you replace user1 and user2 with the usernames of the two partners.
On top of both files you will have five lines of comments as follows:
// assignment 2 |
// partner1-last-name partner1-first-name |
// partner1-username |
// partner2-last-name partner2-first-name |
// partner2-username |
(In the text file you do not need the two slashes)
There will be a separate submission for each problem - it makes it easier to grade each problem, and to provide you with the feedback for each problem wou work on.
The two submissions will be organized as follows:
Submission HW5P1: The log file and the Date.java files in one .zip file
Submission HW5P2: The Banking.zip file that contains your solution to the banking problem.
Due Date: Tuesday, February 11th, 10:59 pm.
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.
Problem 20.2 on page 296
Problem 20.6 on page 305
Problem 20.6 on page 305
Problem 20.8 on page 306
Problem 20.9 on page 306
Problem 21.1 on page 312
Problem 21.3 on page 312
Problem 21.4 on page 315
Problem 21.5 on page 320
Problem 21.6 on page 320
Problem 21.7 on page 320
Problem 1
Finish the problem from Lab 5 that concerns designing constructors for the Date class.
Problem 2
Finish the problem from Lab 5a that concerns designing the same method for the classes that represent bank accounts.