Rectangle

Design a class called “Rectangle” which respects the concept of data hiding and which has the following properties:
Data members :
width (double),
length (double),
x position (double),
y position (double),
numRec (integer)

Methods:
A default constructor that sets the width to 2, the length to 4, the x position to 0 and the y position to 0.
A constructor that accepts 4 parameters – a width, a length, and x position and a y position.
A method called “get_area”. This method should accept no arguments and return the area of the rectangle described using the formula length x width
A method called “get_perimeter”. This method should accept no arguments and return the perimeter of the rectangle described using the formula 2 x length + 2 x width
A method called “getNumberRectangles” with no arguments and which returns the number of rectangles created.

In the main program:
Construct three rectangles using your newly created class using the following information:
Rectangle #0: width of 2, length of 4, position of (0, 0) => use default constructor
Rectangle #1: width of 10, length of 15, position of (5, 3) => use the constructor with 4 parameters
Rectangle #2: width of 3, length of 5, position of (15, 7) => use the constructor with 4 parameters

Finally, write the code that refers to these rectangles and accesses their properties & methods to generate the following output. No user input is required – simply create 3 rectangles using the above information and call the appropriate methods to generate the output below
Rectangle #0
* Coordinates: (0, 0)
* Area: 8
* Perimeter:12Rectangle #1
* Coordinates: (5, 3)
* Area: 150
* Perimeter: 50Rectangle #2
* Coordinates: (15, 7)
* Area: 15
* Perimeter: 16

Last Completed Projects

topic title academic level Writer delivered