dos_compilers/Borland Turbo Pascal v55/POINTS.PAS
2024-07-02 06:49:04 -07:00

88 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ Turbo Points }
{ Copyright (c) 1989 by Borland Interational, Inc. }
unit Points;
{ From P-20 of the Object-Oriented Programming Guide.
}
interface
uses Graph;
type
Location = object
X,Y : Integer;
procedure Init(InitX, InitY : Integer);
function GetX : Integer;
function GetY : Integer;
end;
Point = object (Location)
Visible : Boolean;
procedure Init(InitX, InitY : Integer);
procedure Show;
procedure Hide;
function IsVisible : Boolean;
procedure MoveTo(NewX, NewY : Integer);
end;
implementation
{--------------------------------------------------------}
{ Location's method implementations: }
{--------------------------------------------------------}
procedure Location.Init(InitX, InitY : Integer);
begin
X := InitX;
Y := InitY;
end;
function Location.GetX : Integer;
begin
GetX := X;
end;
function Location.GetY : Integer;
begin
GetY := Y;
end;
{--------------------------------------------------------}
{ Points's method implementations: }
{--------------------------------------------------------}
procedure Point.Init(InitX, InitY : Integer);
begin
Location.Init(InitX, InitY);
Visible := False;
end;
procedure Point.Show;
begin
Visible := True;
PutPixel(X, Y, GetColor);
end;
procedure Point.Hide;
begin
Visible := False;
PutPixel(X, Y, GetBkColor);
end;
function Point.IsVisible : Boolean;
begin
IsVisible := Visible;
end;
procedure Point.MoveTo(NewX, NewY : Integer);
begin
Hide;
Location.Init(NewX, NewY);
Show;
end;
end.