Download the file Rectangle.java and examine
it carefully.
Create a program for each question and implement in inherits.java.
Using inheritance from class Rectangle, create a new class called Square which implements the shape square. (a square is a rectangle with equal witdh and height) Add a main method to the class to execute a suite of test cases. Make sure you document this method by explaining the test cases. You are required to submit Square.java.
Using inheritance from class Rectangle, create a class called SafeRectangle in which height and width can not be set to negative values. If an attempt to violate this restriction is made then an error message will be issued after which the program will immediately abort.
System.exit(1)
shuts down your program
Add a main method to the class to execute a suite of test cases. Make sure you document this method by explaining the test cases. You are required to submit SafeRectangle.java.
Using inheritance from either class Square or SafeRectangle create a class called SafeSquare with a similar added restriction. In the documentation of the class, justify your choice of a parent class. Add a main method to the class to execute a suite of test cases. Make sure you document this method by explaining the test cases. You are required to submit SafeSquare.java
In class Rectangle change the access modifiers of the height and width fields from protected to private, then re-compile your classes. If you get any error messages, modify classes Rectangle, Square, SafeRectangle, SafeSquare so that they are correct with regard to the change. You are required to submit the updated files Rectangle.java, Square.java, SafeRectangle.java and SafeSquare.java.
Suppose we have the following collection of abstract classes and classes: Beaver, Mammal, Dolphin, Flyer, Animal, Emu, Cat, Bird, Walker, Swimmer, Bat, Crow, Cormorant, Penguin. Indicate the following:
Do this in word.