Use best practices and naming conventions.

The first line of each method will be a print statement which prints out the class and method.

The specified method names imply what must be coded in each method, i.e. calcArea method will multiply the width x height and return the result.

After creating all of the methods execute the TestRectangle class and save the output to a file.

Turn in all code and test output in a single file.

Test Class and object creation knowledge.

Write a class named Shape.

Add the following instance variables of type and name , int ID = 0, boolean filled = false, String color = null, Date createdDate = null and a class variable int cnt = 0.

Add methods getId, setId, isFilled, setFilled, getColor, setColor, getDate, setDate, equals. And a constructor with the instance variables as parameter. The setId will read cnt increment the counter and set this value as the id.

Test inheritance knowledge.

Write a class named Rectangle which is inherited from class Shape.

Add the following instance variables of type and name , String name = null, int width = 0, int height = 0.

Add methods getName, setName, getWidth, setWidth, getHeight, setWidth, calcArea and a constructor with the instance variables of both the Circle and Shape classes.

Test overloading and overriding knowledge.

Add a overloaded constructor to Class Rectangle with parameters ID, width and height only

Override the equals method in Class Rectangle which is inherited from the Shape class.

Test pass by value knowledge.

Add a method swap to Class Rectangle which swaps the values of width and height.

Test aggregate knowledge of java and how to test your class.

Create class TestRectangle with a main method.

Print Start of Class rectangle test

In a loop starting at count of 1 create 10 rectangles using the overloaded constructor. Set the height = count and width = count * 2.

Set the remaining variable using the setter routines for all rectangles.

Print the variable values of one selected rectangle.

Using the same rectangle swap the width and height.

Print the variable values of the same rectangle.

Compare two rectangles using the equals methods place a Assert statement that will be true if the rectangles are equal and print Class Rectangle test failed

Select a rectangle and set the width = 2 and height = 2. Get the area of the same rectangle. Add an Assert statement which be true if the area is not equal to 4 and print Class Rectangle test failed.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.