In this assignment, you are asked to write one program. In this program you will define, implement and use a Rectangle class as described below.
Both define and implement a Rectangle class with members as described below. The class definition should be placed in the file rectangle.h and the implementation should be in the file rectangle.cpp; both files should be located in the same project folder. The class members should be as follows:
State Variables | x_center | The location of the center of the rectangle on
the x axis; should be a double |
y_center | The location of the center of the rectangle on
the y axis; should be a double |
|
width | The width of the rectangle on the x axis; should be a double |
|
height | The height of the rectangle on the y axis;
should be a double |
|
Behaviors | constructor: Rectangle() | Initializes all state variables. It assigns 1 to all variables. |
accesssor: GetWidth() | Returns the width of the rectangle | |
accesssor: GetHeight() | Returns the height of the rectangle | |
accesssor: GetX_center() | Returns the x center point of the rectangle | |
accesssor: GetY_center() | Returns the y center point of the rectangle | |
mutator: SetWidth() | Used to set the state variable width | |
mutator: SetHeight() | Used to set the state variable height | |
mutator: SetX_center() | Used to set the state variable x_center | |
mutator: SetY_center() | Used to set the state variable y_center | |
facilitator: Area() | Returns the area of the rectangle | |
facilitator: Perimeter() | Returns the perimeter of the rectangle | |
facilitator: Display() | Prints to cout rows and columns of
*'s representing the height and width of the rectangle. For example, a rectangle with width=2 and height=3 should be displayed as a block of *'s that is 2 columns wide and 3 rows height. It is not necessarily to correctly position the center of the rectangle. |
Write a program that creates 2 rectangle objects, prints their area and perimeter and then displays the objects. The height and width of these objects should be changed using the mutator functions and then the area and perimeter should be reprinted and the objects should be redisplayed. This program should be in a file called prog.cpp located in the same project as the class definition and implementation. Here is an example of an acceptable prog.cpp .
Place the following files in your class ftp directory: rectangle.h, rectangle.cpp, and prog.cpp.