Question: Start with a working Point class. Refer to the Point program created for Lab # 1 : 2 . Write a new Rectangle class, a

Start with a working Point class. Refer to the Point program created for Lab #1:
2. Write a new Rectangle class, a subclass of the Point class.
a. Add width and length variables to the new class.
b. Add constructors
i. a default Rectangle()where width =15, length =15
ii. a 2 argument constructor Rectangle(width, length)
iii. use the Super() default constructor for the x, y values
c. Add get () and set () methods as needed to support your new instance variables.
d. Add a method called area that:
i. Calculates the area of a Rectangle object: Area= length * width
ii. returns the Area of a Rectangle object
iii. Do not store the area in a member variable.
e. Override the toString method found in class Point to display (and label) all of the characteristics
(instance variables) of a Rectangle object. Do not forget to include the original point instance
variables by using the super.toString().
3. Write a new Box class, a subclass of the Rectangle class.
a. Add height as a new variable in this class
b. Add constructors
i. a default Box() where width =15, length =15, height =15
ii. a 1 argument constructor Box(height)
iii. use the Super() default constructor for the x, y, width, height values
c. Add get () and set () methods as needed.
d. Override the area method inherited from the Rectangle class to calculate the outside face area (6
sides) of a Box object.
i. Calculates: Area= length * width *2+ width * height *2+ length * height *2
ii. returns the area of a Rectangle object
iii. Do not store the area in a member variable.
e. Add a method called volume that:
i. Calculates the volume of a Box object: Volume = length * width * height.
ii. returns the volume of a Box object
Lab 2- Advanced Java
Inheritance
Rev. 1/21/20237:02 PM
iii. Do not store the volume in a member variable.
f. Override the toString method inherited from class Rectangle to display (and label) all of the
characteristics (instance variables) of a Box object. Do not forget to include the original point
and rectangle instance variables by using the super.toString().
4. Write an executable client class called ShapesTester a separate program - that uses the Point,
Rectangle and Box classes.
a. Print your name, Lab number, and date as the first three lines of output. Hard-code the date...do
not use the system date.
b. Create two objects of type Point,
i. point1= Point()
ii. point2= Point(5,19)
c. Create two objects of type Rectangle
i. rectangle1= Rectangle()
ii. rectangle2= Rectangle(24,30)
d. Create two objects of type Box.
i. box1= Box()
ii. box2= Box(60)
e. Execute the area () methods for all objects of type Rectangle and Box. The area should be
printed from the ShapesTester class. Remember the area is being returned to the client.
f. Execute the volume () and area() methods for all objects of type Box. The volume should be
printed from the Shapes class. Remember the volume is being returned to the client.
g. Change the width of box2 to 21
h. Execute the volume () and area() methods for box2. The volume should be printed from the
ShapesTester class. Remember the volume is being returned to the client.
i. Execute the toString () method for all objects.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!