Help Drawing a House and filling with Characters

I am supposed to be creating a house with characters that combine an empty equilateral triangle and an empty square and both are to be filled in with other characters.
It's not going to show correctly, but it is supposed to look like an
empty arrow but can be filled with characters. the top triangle is an equilateral triangle on top of a square and the triangle is to be 2 sizes biggire than the square.
This supposed to be a test for a draw(); function for a house class that the size entered through a driver changes the size of the house, border, and fill.
I made a separate cPP file trying to test how the shape should show.
This is the only part that confuses me.
Here's my code:
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
int times;
char star = '*';

int l = 1;

for (int i = 0;i<7;i++)
{
for (int j = 7; j>i;j--)
{
cout << " ";

}
cout << star;
if(i!=0)
{
for(int k= 1;k<=l;k++)
{
cout << " ";
}
cout << star;
l+=2;

}

cout << endl;

}

for(int s =0;s<5;s++){
for(int i =0;i < 7;i++){
cout << " ";
cout << star;

}

cout<<endl;
}

return 0;
}

Last edited on
This supposed to be a draw(); function for a house class

You don't have a house class at all.
Note that the draw() function takes the size as an argument.
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
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <iomanip>
using namespace std;

const char star = '*';

class House
{   
public:
    void Draw (int size);
};

void House::Draw (int size)
{   int l = 1;

    for (int i = 0;i<size;i++)
    {   for (int j = size; j>i; j--)
        {   cout << " ";
        }
        cout << star;
        if (i!=0)
        {   for (int k=1; k<=l; k++)
            {   cout << " ";
            }
            cout << star;
            l+=2;

        }
        cout << endl;
    }
    for(int s=0; s<size-2; s++)
    {   for (int i =0; i<size;i++)
        {   cout << " ";
            cout << star;
        }
        cout<<endl;
    }
}
    
int main() 
{   House   house;

    house.Draw (8);   
    system ("pause");
    return 0;
}


PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Last edited on
I know I don't have a house class, this is a separate test cpp file .
Topic archived. No new replies allowed.