I'm trying to write a method that draws a rectangle. If the user enters height = 4, and width = 8, and the print of character " * ", then the left rectangle is drawn on the left if the filled flag is true. If the flag is false, then version on the right is drawn which would be an empty rectangle.
* * * * * * * * ||||| * * * * * * * *
* * * * * * * * ||||| *e m p t y *
* * * * * * * * ||||| *e m p t y *
* * * * * * * * ||||| * * * * * * * *
I've written the below so far, where am I going wrong?:
rec()
{
if (filled == true)
{
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << "*";
}
cout << endl;
}
}
else // this is the empty rectangle
{
for (int row = 0 ; row < height; row++)
{
for (int col = 0; col < width; col++)
{
cout << "*" << setw(width-1) << "*";
}
cout << endl;
}
}