Код
Uses Graph, CRT;
Type
GraphObj = object
X,Y: Integer;
Color: Word;
Constructor Init(aX,aY:Integer;AColor:Word);
Procedure Draw(aColor:Word); Virtual;
Procedure Show;
Procedure Hide;
Procedure Move(dX,dY:Integer);
end;
Constructor GraphObj.Init;
begin
X:=aX;
Y:=aY;
end;
Procedure GraphObj.Draw;
begin
end;
Procedure GraphObj.Show;
begin
Draw(Color);
end;
Procedure GraphObj.Hide;
begin
Draw(GetBkColor);
end;
Procedure GraphObj.Move;
begin
Hide;
X:=X+dX;
Y:=Y+dY;
Show
end;
Type
Point = object(GraphObj)
Procedure Draw(aColor:Word); Virtual;
end;
Procedure Point.Draw;
begin
PutPixel(520,290,white);
end;
Var
d,r,q:Integer;
ln:Line;
begin
D:=Detect;
InitGraph(d,r,'');
Ln.Init(200,200,white);
Ln.Draw(red);
Repeat
ln.Move(-10,10);
Until
q>100;
End.