Hello all,
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
Code:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh)
{ add(Point (p));}
void draw_lines () const
{
fl_line(point(0).x, point(0).y, point(0).x, point(0).y+_long, point(0).x+_short, point(0).y+_long);
fl_line(point(0).x+_short, point(0).y+_long, point(0).x, point(0).y);
}
private:
Point c;
int _long, _short;
};
//*********************************
int main()
{
Simple_window win(Point(100,100), 700,500, "Octagon");
Point p(200,200);
int l = 80, sh = 60;
right_triangle rt(p,l,sh);
win.attach(rt);
win.wait_for_button();
}
But it sounds that making an octagon using eight right triangles isn't possible!
What's your thoughts please?