The purpose of this lab is to
- Understand and practice the use of composition in program design
- Reinforce the idea of code reuse
- Understand the concept, implementation, and use of copy constructors
- Experience the use of static method calls
In this lab, you will be implementing two classes - Rectangle and Point.
We will define a rectangle by the coordinates of its four corners. We will also write methods to compute the area and perimeter of a given rectangle from these four points. Your program will prompt for the x- and y-coordinates of the four corners, referred to as "UpperLeft", "LowerLeft", "LowerRight" and "UpperRight".
The description of the classes is as follows:
The Point class represents the x- and y-coordinates of a single point in the
coordinate plane. This class is defined in
Rectangle class will use the Point class to represent each of its four
The Rectangle class represents a rectangle in the coordinate plane. The
Point class is used to store the x- and y-coordinates of its four corners.
This class is defined in
Rectangle.java . The constructor will
have four Point objects as arguments, corresponding to the upperLeft,
lowerLeft, lowerRight, and upperRight corners. The Rectangle class will
also have methods to calculate the length, area, and perimeter of a given