Reputation: 164
I have my class:
class Rectangle : public TwoDim
{
public:
void fun() {};
void printShape();
Rectangle(int x1, int y1, int height1, int width1)
{
x = x1;
y = y1;
height = height1;
width = width1;
}
};
And the function to print it:
void Rectangle::printShape()
{
{
cout << "+";
for (int i = 0; i < width - 2; i++)
{
cout << "-";
}
cout << "+\n";
for (int i = 0; i < height - 2; i++)
{
cout << "|";
for (int j = 0; j < +width - 2; j++)
{
cout << " ";
}
cout << "|\n";
}
cout << "+";
for (int i = 0; i < width - 2; i++)
{
cout << "-";
}
cout << "+\n";
}
}
How do I change my function such that I will draw the rectangle starting from the point (x, y)
?
Thanks a lot
Upvotes: 1
Views: 2594
Reputation: 258648
I'd start by outputting y
std::endl
s before the actual printing, and then outputting x
" "
before effectively printing each row.
Upvotes: 1