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

1. Write a

- (5pt) A constructor which takes no parameters, and set both
*x*and*y*to zero. - (5pt) A constructor which takes two parameters, and set
*x*and*y*to the given values. - (5pt) A constructor which takes a
*Point*object as parameter, and set*x*, and*y*to the coordinates of the given point. - (10pt) Get and set methods for both
*x*and*y*. For example,*getX*returns the x coordinate,*setX*sets the x coordinate to a given value. - (10pt) A method
*distance*which returns the distance to a given point. Note that this method should take only one parameter, e.g.*Point p*, not two parameters.

- (5pt) A constructor which takes no parameters. By default the rectangle has two corner points (0,0) and (0,0). Note that in this case the rectangle degenerates to a point, but that's fine.
- (5pt) A constructor which takes two
*Point*parameters. - (20pt) Methods
*width*,*height*,*perimeter*, and*area*, which return the width, height, perimeter, and area of the rectangle, respectively. - (15pt) A method
*isOverlapping*, which checks if a rectangle overlaps with a given rectangle. Note that overlapping includes the case where one rectangle is completely inside another rectangle.

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

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