Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
46
Task/Classes/Component-Pascal/classes.component
Normal file
46
Task/Classes/Component-Pascal/classes.component
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
MODULE Graphics;
|
||||
IMPORT StdLog;
|
||||
TYPE
|
||||
(* class *)
|
||||
Point* = POINTER TO LIMITED RECORD
|
||||
x-,y-: INTEGER; (* Instance variables *)
|
||||
END;
|
||||
|
||||
(* method *)
|
||||
PROCEDURE (p: Point) Abs*(): INTEGER,NEW;
|
||||
BEGIN
|
||||
RETURN p.x
|
||||
END Abs;
|
||||
|
||||
(* method *)
|
||||
PROCEDURE (p: Point) Ord*(): INTEGER,NEW;
|
||||
BEGIN
|
||||
RETURN p.y
|
||||
END Ord;
|
||||
|
||||
(* method *)
|
||||
PROCEDURE (p: Point) Show*,NEW;
|
||||
BEGIN
|
||||
StdLog.String("Point(");StdLog.Int(p.x);StdLog.String(",");
|
||||
StdLog.Int(p.y);StdLog.String(");");StdLog.Ln
|
||||
END Show;
|
||||
|
||||
(* constructor *)
|
||||
PROCEDURE NewPoint*(x,y: INTEGER): Point;
|
||||
VAR
|
||||
p: Point;
|
||||
BEGIN
|
||||
NEW(p);p.x := x;p.y := y;
|
||||
RETURN p
|
||||
END NewPoint;
|
||||
|
||||
PROCEDURE TestPoint*;
|
||||
VAR
|
||||
p: Point;
|
||||
BEGIN
|
||||
p := NewPoint(10,20);
|
||||
p.Show();
|
||||
StdLog.String("Abs:> ");StdLog.Int(p.Abs());StdLog.Ln;
|
||||
StdLog.String("Ord:> ");StdLog.Int(p.Ord());StdLog.Ln
|
||||
END TestPoint;
|
||||
END Graphics.
|
||||
Loading…
Add table
Add a link
Reference in a new issue