Помогите пожалуйста исправить программу, которая выполняла бы движение треугольника по треугольному контуру.
Код: Program Graphworld;
Uses Graph;
Type
Location = object
x,y :integer;
constructor Init (initX, initY :integer);
destructor Done;
function GetX :integer;
function GetY :integer;
end;
Constructor Location.Init (initX, initY :integer);
Begin
X:=InitX;
Y:=InitY
End;
Destructor Location.Done;
Begin
End;
Function Location.GetX:integer;
Begin
GetX:=x;
End;
Function Location.GetY:integer;
Begin
GetY:=y;
End;
{=======================================================================}
Type Point = object (Location)
visible:boolean;
Procedure Show; virtual;
Procedure Hide; virtual;
Procedure Moveto (newX, newY :integer);
End;
Procedure Point.Show;
Begin
Putpixel(x, y, Getcolor);
Visible:=TRUE
End;
Procedure Point.Hide;
Begin
Putpixel(x, y, GetBkColor);
Visible:=FALSE
End;
Procedure Point.Moveto;
Var TempVisible:boolean;
Begin
TempVisible:=visible;
If TempVisible then Hide;
X:=newX;
Y:=newY;
If TempVisible then Show;
End;
{=======================================================================}
Type Circle = object (Point)
Radius :integer;
Constructor Init (initX, initY, initR :integer);
Procedure Show; virtual;
Procedure Hide; virtual;
Function Getradius :integer;
end;
Constructor Circle.Init;
Begin
X:=initX;
Y:=initY;
Radius:=initR
End;
Procedure Circle.Show;
Begin
Graph.circle(x, y, radius);
Visible:=TRUE
End;
Procedure Circle.Hide;
Var tempcolor :word;
Begin
Tempcolor:=Getcolor;
Setcolor(Getbkcolor);
Graph.Circle(x, y, radius);
Setcolor(Tempcolor);
Visible:=FALSE
End;
Function Circle.Getradius;
Begin
Getradius:=radius;
End;
{=============================================================================}
Type World = object
Mode :integer;
Driver :integer;
Procedure Initworld(gdr, gmode :integer; path :string);
Procedure Endworld;
End;
Procedure World.Initworld;
Var rez :integer;
Begin
Driver:=gdr;
Mode:=gmode;
Initgraph(driver, mode, path);
Rez:=Graphresult;
If rez<>GrOK then
Begin
Writeln(GraphErrorMsg(rez));
Halt(1);
End;
End;
Procedure World.Endworld;
Begin
Closegraph;
Writeln('The end of the world.');
End;
Type ppoint = ^point;
pcircle = ^circle;
Var namepathdriver :string;
W :world;
Pt point;
Pc circle;
Begin
{ инициализация мира }
writeln('Путь к драйверу');
readln(namepathdriver);
w.initworld(detect, detect, namepathdriver);
{ рождение объектов }
pt:=new(ppoint,init(100,100));
pc:=new(pcircle,init(200,200,100));
{ развитие объектов }
pt^.show;
pc^.show;
readln;
pt^.moveto(50, 50);
pc^.moveto(390, 390);
readln;
{ смерть объектов }
dispose(pt,done);
dispose(pc,done);
{ конец мира }
w.endworld;
readln;
End.
Код: Program Graphworld;
Uses Graph;
Type
Location = object
x,y :integer;
constructor Init (initX, initY :integer);
destructor Done;
function GetX :integer;
function GetY :integer;
end;
Constructor Location.Init (initX, initY :integer);
Begin
X:=InitX;
Y:=InitY
End;
Destructor Location.Done;
Begin
End;
Function Location.GetX:integer;
Begin
GetX:=x;
End;
Function Location.GetY:integer;
Begin
GetY:=y;
End;
{=======================================================================}
Type Point = object (Location)
visible:boolean;
Procedure Show; virtual;
Procedure Hide; virtual;
Procedure Moveto (newX, newY :integer);
End;
Procedure Point.Show;
Begin
Putpixel(x, y, Getcolor);
Visible:=TRUE
End;
Procedure Point.Hide;
Begin
Putpixel(x, y, GetBkColor);
Visible:=FALSE
End;
Procedure Point.Moveto;
Var TempVisible:boolean;
Begin
TempVisible:=visible;
If TempVisible then Hide;
X:=newX;
Y:=newY;
If TempVisible then Show;
End;
{=======================================================================}
Type Circle = object (Point)
Radius :integer;
Constructor Init (initX, initY, initR :integer);
Procedure Show; virtual;
Procedure Hide; virtual;
Function Getradius :integer;
end;
Constructor Circle.Init;
Begin
X:=initX;
Y:=initY;
Radius:=initR
End;
Procedure Circle.Show;
Begin
Graph.circle(x, y, radius);
Visible:=TRUE
End;
Procedure Circle.Hide;
Var tempcolor :word;
Begin
Tempcolor:=Getcolor;
Setcolor(Getbkcolor);
Graph.Circle(x, y, radius);
Setcolor(Tempcolor);
Visible:=FALSE
End;
Function Circle.Getradius;
Begin
Getradius:=radius;
End;
{=============================================================================}
Type World = object
Mode :integer;
Driver :integer;
Procedure Initworld(gdr, gmode :integer; path :string);
Procedure Endworld;
End;
Procedure World.Initworld;
Var rez :integer;
Begin
Driver:=gdr;
Mode:=gmode;
Initgraph(driver, mode, path);
Rez:=Graphresult;
If rez<>GrOK then
Begin
Writeln(GraphErrorMsg(rez));
Halt(1);
End;
End;
Procedure World.Endworld;
Begin
Closegraph;
Writeln('The end of the world.');
End;
Type ppoint = ^point;
pcircle = ^circle;
Var namepathdriver :string;
W :world;
Pt point;
Pc circle;
Begin
{ инициализация мира }
writeln('Путь к драйверу');
readln(namepathdriver);
w.initworld(detect, detect, namepathdriver);
{ рождение объектов }
pt:=new(ppoint,init(100,100));
pc:=new(pcircle,init(200,200,100));
{ развитие объектов }
pt^.show;
pc^.show;
readln;
pt^.moveto(50, 50);
pc^.moveto(390, 390);
readln;
{ смерть объектов }
dispose(pt,done);
dispose(pc,done);
{ конец мира }
w.endworld;
readln;
End.