home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l044 / 4.ddi / DOCDEMOS.ZIP / POINTS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-10-23  |  1.6 KB  |  87 lines

  1.  
  2. { Turbo Points }
  3. { Copyright (c) 1989,90 by Borland International }
  4.  
  5. unit Points;
  6. { From Chapter 4 the Turbo Pascal 6.0 User's Guide. }
  7.  
  8. interface
  9.  
  10. uses Graph;
  11.  
  12. type
  13.   Location = object
  14.     X,Y: Integer;
  15.     procedure Init(InitX, InitY: Integer);
  16.     function GetX: Integer;
  17.     function GetY: Integer;
  18.   end;
  19.  
  20.   Point = object(Location)
  21.     Visible: Boolean;
  22.     procedure Init(InitX, InitY: Integer);
  23.     procedure Show;
  24.     procedure Hide;
  25.     function IsVisible: Boolean;
  26.     procedure MoveTo(NewX, NewY: Integer);
  27.   end;
  28.  
  29. implementation
  30.  
  31. {--------------------------------------------------------}
  32. { Location's method implementations:                     }
  33. {--------------------------------------------------------}
  34.  
  35. procedure Location.Init(InitX, InitY: Integer);
  36. begin
  37.   X := InitX;
  38.   Y := InitY;
  39. end;
  40.  
  41. function Location.GetX: Integer;
  42. begin
  43.   GetX := X;
  44. end;
  45.  
  46. function Location.GetY: Integer;
  47. begin
  48.   GetY := Y;
  49. end;
  50.  
  51.  
  52. {--------------------------------------------------------}
  53. { Points's method implementations:                       }
  54. {--------------------------------------------------------}
  55.  
  56. procedure Point.Init(InitX, InitY: Integer);
  57. begin
  58.   Location.Init(InitX, InitY);
  59.   Visible := False;
  60. end;
  61.  
  62. procedure Point.Show;
  63. begin
  64.   Visible := True;
  65.   PutPixel(X, Y, GetColor);
  66. end;
  67.  
  68. procedure Point.Hide;
  69. begin
  70.   Visible := False;
  71.   PutPixel(X, Y, GetBkColor);
  72. end;
  73.  
  74. function Point.IsVisible: Boolean;
  75. begin
  76.   IsVisible := Visible;
  77. end;
  78.  
  79. procedure Point.MoveTo(NewX, NewY: Integer);
  80. begin
  81.   Hide;
  82.   Location.Init(NewX, NewY);
  83.   Show;
  84. end;
  85.  
  86. end.
  87.