i write a class definition for a rectangle class that contains two int fields length 5346318

I. Write a class definition for a Rectangle class that contains:

· Two int fields, length and width.

· Mutator and accessor methods for the length and width fields.

· A Boolean method named isSquare that returns true if the rectangle’s length and width are the same and false otherwise.

II. Write a class definition for a RectangleDriver class that contains a main method that acts as a driver for the Rectangle class of the previous problem. The main method should do this:

· Construct a Rectangle object named rect.

· Use the mutator methods to prompt the user for values to rect’s length and width fields.

· Use the Boolean method to determine if rect is a square.

o If rect is a square, print “Square: ” and then the square’s dimensions. For example:

Square: 4×4

o If rect is not a square, print “Rectangle: ” and then the rectangle’s dimensions. For example:

Rectangle: 6×13

· In printing the above messages, use the accessor methods to retrieve the rectangle’s dimensions.

III. Add a print method to the rectangle class, which prints a rectangle of asterisks corresponding to the dimensions of the rectangle; if the width is greater than 40 or the height is greater than 24 instead of printing the rectangle with asterisks, display the message “too big to print”.

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now