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
|
#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();
}
|