Written in C# with //commentation
Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods:
Two Class variables of type double named height and width to represent the
Written in C# with //commentation
Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods:
Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor.
A non-argument constructor method to create a default rectangle.
Another constructor method to create a rectangle with user-specified height and width.
Method getArea() that returns the area.
Method getPerimeter() that returns the perimeter.
Method getHeight() that returns the height.
Method getWidth() that returns the width.
Now design and implement a test program to create two rectangle objects: one with default height and width, and the second is 5 units high and 6 units wide. Next, test the class methods on each object to print the information as shown below.
Height: 1 unit
Width: 1 unit
Area: 1 unit
Perimeter: 4 units
Height: 5 unit
Width: 6 unit
Area: 30 units
Perimeter: 22 units