Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
iLAB STEPS SECTION 1: Rectangle.java Back to Top Write a class called Rectangle. It should have length and width attributes that default to 1 if they...
iLAB STEPS
SECTION 1: Rectangle.javaBack to Top
Write a class called Rectangle. It should have length and width attributes that default to 1 if they are not set. It should have appropriate get and set methods for getting and setting the attributes. It should also have a perimeter() method that returns the perimeter of the rectangle. It should also have an area() method that returns the area of the rectangle. It should also have a getType() method that either returns a String with the value of "Rectangle" or prints that string value out.
SECTION 2: Square.javaBack to Top
Write a class called Square that is a child class of Rectangle. A square is a rectangle with equal sides. It should inherit the perimeter() and area() methods. It should also inherit the get and set methods for each attribute, if that is appropriate. The Square class should override the getType() method from the superclass so that it returns or outputs "Square."
SECTION 3: TestDriver.javaBack to Top
Write a class called TestDriver that demonstrates all of the code in your Rectangle class and your Square class. The TestDriver class should do the following:
- Create a Rectangle and a Square.
- Go into a loop where it asks the user if they want a Rectangle or Square.
- Read user answer.
- If user wants to quit, then exit the program.
- If user wants a Rectangle, ask user for width and length. If user wants a Square, ask user for the length of one side.
- Display the type (Rectangle or Square), the length, width, area, and perimeter.
- Return to Step 2.