Help needed! drawing a diamond
Jan 24, 2012 at 3:17pm UTC
Hey guys, i have a project due for class where we have to draw a diamond using for loops. I've got most of it done except the draw function. If you guys can help me write the draw function or point me in the right direction i'd appreciate it!
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#include "diamond.h"
using namespace std;
Diamond::Diamond (int size, char borderchar, char fillchar)
{
if (size<1)
{
size=1;
}
if (size>39)
{
size=39;
}
SetBorder(borderchar);
SetFill(fillchar);
}
int Diamond::GetSize()
{
return size;
}
int Diamond::Perimeter()
{
return size*4;
}
int Diamond::Area()
{
return size*size;
}
void Diamond::Grow()
{
if (size <=38 && size >= 1)
size=size++;
else
size=1;
}
void Diamond::Shrink()
{
if (size >=2 && size<=40)
size=size--;
else
size=1;
}
void Diamond::SetBorder(char borderchar)
{
if (borderchar >='!' && borderchar <='~' )
{
border = borderchar;
}
else
{
border = '#' ;
}
}
void Diamond::SetFill(char fillchar)
{
if (fillchar >='!' && fillchar <='~' )
{
fill = fillchar;
}
else
{
fill = '*' ;
}
}
void Diamond::Draw()
{
for (
Jan 24, 2012 at 4:55pm UTC
Topic archived. No new replies allowed.