Question: 1. The class Shape will contain two instance variables: String color and String name_object. Define the default constructor with no arguments(the initialization for this case

1. The class Shape will contain two instance variables: String color and String name_object. Define the default constructor with no arguments(the initialization for this case will be color=white, name_object= ), the constructor with parameters, get/set methods of data fields and the method toString() that returns a string description of object. 2. Design the Rectangle class that will inherit from Shape class and implement the interface Comparable. The interface Comparable is defined as : public interface Comparable { int compareTo(T); } This class will have two instance variale of type double: height and width. Define the constructor with parameters, get/set methods for these variables, the methods named getArea() and getPerimeter() that returns the area and perimeter of this rectangle and the methos toString() that returns a string description for the rectangle. The method compareTo should use the perimeter for the comparison of the rectangles. 3. Design the class Square which inherits from the class Rectangle. It has only one instance variable side. Implement the constructor with one parameter and method toString. 4. Write a test program that creates objects of type Rectangle and Square. Create a small menu for creating a rectangle, square or for quitting the program. Display which object has the maximum perimeter.

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!