1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include "square.h"
square::square (string shapeName, bool shapeContainsWarpSpace, int newX1, int newX2, int newX3, int newX4, int newY1, int newY2, int newY3, int newY4):shapeTwoD(shapeName,shapeContainsWarpSpace)
{
x[0] = newX1;
x[1] = newX2;
x[2] = newX3;
x[3] = newX4;
y[0] = newY1;
y[1] = newY2;
y[2] = newY3;
y[3] = newY4;
}
string square::toString()
{
stringstream oss;
string toString;
oss << "name = "<<shapeTwoD::getName()<<"\ncontainsWarpSpace = "<<shapeTwoD::getContainsWarpSpace()<<"\nx1 = "<<x[0]<<"\nx2 = "<<x[1]<<"\nx3 = "<<x[2]<<"\nx4 = "<<x[3]<<"\ny1 = "<<y[0]<<"\ny2 = "<<y[1]<<"\ny3 = "<<y[2]<<"\ny4 = "<<y[3]<<endl;
toString=oss.str();
return toString;
}
int main()
{
square s("square",false,1,2,3,4,1,2,3,4);
cout<<"\nx4 = "<<s.getX4()<<endl<<endl;
cout<<s.toString()<<endl;
return 0;
};
|