Homework 2
CS202, Summer 2004


Due: Thursday, July 8

Please email your solutions to csun@calstatela.edu, and make sure to use CS202 Summer 04 HW2 as the subject of the email. The email should include your name, and the .java files for all the exercises as attachments. For all homework assignments and projects, failing to comply with the required code conventions (see Review of Language Basics, slide #7) will incur a credit penalty up to 10% of the total credit for the assignment.


1. Write a Point class which has two private double fields x and y, which correspond to the x and y coordinates of a point. Include the following methods in the class:
2. Re-use your Point class and write a new class Rectangle. Rectangle has two Point fields, lowerLeft and upperRight, which correspond to the two corner points of a rectangle. Include the following methods in the class:
3. (10pt) Write a GeometryTest class which only has a main method. Inside the main method, create a few Point and Rectangle objects, and properly test all methods of these two classes, including all the constructors.

4. (20pt) [D&D] 11.24

5. (20pt) [D&D] 11.25