In Java, This exercise is a continuation of the last one. Createa new project and a new main class as
usual. Now copy the Rectangle class from the last exercise to thisone which is.
public static void PrintRectangleInformation(Rectangle r){
System.out.println(“Height: ” + r.getHeight());
System.out.println(“Width: ” + r.getWidth());
System.out.println(“Area: ” + r.Area());
System.out.println(“Perimeter: ” + r.Perimeter());
if (r.isSquare())
System.out.println(“The rectangle is a square.”);
else
System.out.println(“The rectangle is not a square.”);
In the constructor
and the setWidth and setHeight methods, add in data validitychecking. If either the
width or the height comes in as less than 0 set it to 0.
In the main le:
(a) Copy the PrintRectangleInformation method over from the lastproject.
(b) Insert the following