Code the following class Hopefully the method names clearly
) Code the following class. Hopefully the method names clearly imply the specific purpose of each. Note that – indicates private and + is public
(Rectangle)
- xCoordinate : int
- yCoordinate : int
- height:int
- width:int
- color:string
+ Rectangle(x:int,y:int,h:int,w:int)
+ setHeight(h:int): void
+ setWidth(w:int): void
+ setColor(c:string): void
+ setXCoordinate(new X:int): void
+ setYCoordinate(new Y:int): void
+getHeight():int
+getWidth():int
+getColor():string
+getXCoordinate():int
+getYCoordinate():int
.
| (Rectangle) - xCoordinate : int - yCoordinate : int - height:int - width:int - color:string |
| + Rectangle(x:int,y:int,h:int,w:int) + setHeight(h:int): void + setWidth(w:int): void + setColor(c:string): void + setXCoordinate(new X:int): void + setYCoordinate(new Y:int): void +getHeight():int +getWidth():int +getColor():string +getXCoordinate():int +getYCoordinate():int |
Solution
Rectangle.cpp
#include <iostream>
using namespace std;
class Rectangle{
private:
int xCoordinate;
int yCoordinate;
int height;
int width;
string color;
public:
Rectangle(int x,int y,int h,int w){
height =h;
width = w;
xCoordinate = x;
yCoordinate = y;
}
void setHeight(int h){
height = h;
}
void setWidth(int w){
width = w;
}
void setColor(string c){
color = c;
}
void setXCoordinate(int X){
xCoordinate = X;
}
void setYCoordinate(int Y){
yCoordinate = Y;
}
int getHeight(){
return height;
}
int getWidth(){
return width;
}
string getColor(){
return color;
}
int getXCoordinate(){
return xCoordinate;
}
int getYCoordinate(){
return yCoordinate;
}
};
int main()
{
return 0;
}


