Assignment 7
This is the first part of assignment 7. It should be straightforward, as it asks you to finish the work you have started in the lab.
You will submit it separately form the second part, as the second part requires that you provide complete JAvadoc documentation and WebCAT will check your compliance.
Learn to override the methods equals, hashCode, and toString.
Learn to define and use visitors.
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.
Submission Details:
Make sure the the names of all classes and interfaces in all three problems are different.
Make sure every file with name Xyyy.java contains as the first class or interface the definition of class Xyyy or interface Xyyy
Make sure that the three classes with tests for the three problems are named Examples... as appropriate.
Due Date: Friday, November 15, 10:00 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.
Review the Lecture Notes on hashCode and equals methods).
Design the hashCode and equals methods for the classes that represent shapes, namely Circle, Rectangle,and Combo.
Design the ShapeVisitorDouble for a method that produces a double value. Then design the AreaVisitor and DistTo0Visitor that compute the area of a shape and the distance to the origin, respectively.
Problem 1: hashCode and equals
Finish the Part 1 from Lab 10.
Hand in the code from the lab that includes the implementation of the following methods (with the appropriate test, of course!):
The toString method for the classes City and State
The equals method for the class City
The hashCode method for the class City
The initMap method in the class Examples
Problem 2: Visitors
Finish the Visitors section from Lab 10a.
Hand in the code from the lab that includes the implementation of the following methods and classes (with the appropriate test, of course!):
Make another example of the use of the ILoImageDownloadTimeVisitor that computes the download time with the download speed 100 for the list ilist3.
Design a visitor that implements the method that produces a list of titles of all songs in a list of songs. Of course, you need to make sure that your solution works.
Design a visitor class that implements the method that produces one long String that contains the titles of all books, separating the titles with the new line String that is encoded as "\n". Of course, you need to make sure that your solution works.