Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
41
Task/Classes/Component-Pascal/classes-1.pas
Normal file
41
Task/Classes/Component-Pascal/classes-1.pas
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
MODULE Point;
|
||||
IMPORT
|
||||
Strings;
|
||||
TYPE
|
||||
Instance* = POINTER TO LIMITED RECORD
|
||||
x-, y- : LONGINT; (* Instance variables *)
|
||||
END;
|
||||
|
||||
PROCEDURE (self: Instance) Initialize*(x,y: LONGINT), NEW;
|
||||
BEGIN
|
||||
self.x := x;
|
||||
self.y := y
|
||||
END Initialize;
|
||||
|
||||
(* constructor *)
|
||||
PROCEDURE New*(x, y: LONGINT): Instance;
|
||||
VAR
|
||||
point: Instance;
|
||||
BEGIN
|
||||
NEW(point);
|
||||
point.Initialize(x,y);
|
||||
RETURN point
|
||||
END New;
|
||||
|
||||
(* methods *)
|
||||
PROCEDURE (self: Instance) Add*(other: Instance): Instance, NEW;
|
||||
BEGIN
|
||||
RETURN New(self.x + other.x,self.y + other.y);
|
||||
END Add;
|
||||
|
||||
PROCEDURE (self: Instance) ToString*(): POINTER TO ARRAY OF CHAR, NEW;
|
||||
VAR
|
||||
xStr,yStr: ARRAY 64 OF CHAR;
|
||||
str: POINTER TO ARRAY OF CHAR;
|
||||
BEGIN
|
||||
Strings.IntToString(self.x,xStr);
|
||||
Strings.IntToString(self.y,yStr);
|
||||
NEW(str,128);str^ := "@(" +xStr$ + "," + yStr$ + ")";
|
||||
RETURN str
|
||||
END ToString;
|
||||
END Point.
|
||||
17
Task/Classes/Component-Pascal/classes-2.pas
Normal file
17
Task/Classes/Component-Pascal/classes-2.pas
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
MODULE DrivePoint;
|
||||
IMPORT
|
||||
Point,
|
||||
StdLog;
|
||||
|
||||
PROCEDURE Do*;
|
||||
VAR
|
||||
p,q: Point.Instance;
|
||||
BEGIN
|
||||
p := Point.New(1,2);
|
||||
q := Point.New(2,1);
|
||||
StdLog.String(p.ToString() + " + " + q.ToString() + " = " + p.Add(q).ToString());StdLog.Ln;
|
||||
StdLog.String("p.x:> ");StdLog.Int(p.x);StdLog.Ln;
|
||||
StdLog.String("p.y:> ");StdLog.Int(p.y);StdLog.Ln
|
||||
END Do;
|
||||
|
||||
END DrivePoint.
|
||||
Loading…
Add table
Add a link
Reference in a new issue