: -
: TURBO PASCAL 7.1
: ,
: 2 .
:
1. . , .. - . . .: ,2005. . 15-33, 38-41, 54-55, 68-75-93, 101-130.
2. .. Turbo Pascal. . 2- . .: , 2007. . 156-172.
3. ., . Turbo Pascal. .: , 2008. . 293-309.
4. .. . . . .: , 2008. . 175-198.
: 2 .
:
1. .
2. .
- () , . .
, .
: , , , . .
.
― .
, , . .
.
, , - , .
, , . , . .
:
― , ;
― , .. ;
― ;
― ;
― .
. . , .
|
|
― , . . , .
Type = object
[private ()]
[public ()]
end;
, .. , .
, .. , .
.
. . .
Var Vasya: monstr; { }
pm: ^monstr; { }
new (pm); { }
, .
, .
, . object.
Type deamon = object(monstr)
. , . . , , .
. , , . .
.
( ).
- Dispose ― .
Type monstr = object
procedure init(x_, y_, health, ammo_:word);
procedure attack;
procedure draw;
procedure erase;
procedure hit;
procedure move(x_, y_:word);
private
x, y: word;
health, ammo: word;
color: word;
end;
.
, , , :
Procedure monstr.init (x_, y_, health, ammo_:word);
begin
x: = x_;
y: = y_;
health: = health_;
ammo: = ammo_;
color: = yellow;
end;
procedure monstr.draw;
begin
setcolor(color);
outtextXY(x, y, @);
end;
|
|
: - .
Program polytest;
uses crt;
type
fatherprt = ^father;
father = object
age: integer;
constructor init;
procedure talk; virtual;
end;
sonprt = ^ son;
son = object (father)
girlfriend: integer;
constructor init;
procedure talk; virtual;
end;
Var
sergei: father;
anton: son;
link: fatherprt;
constructor father.init;
begin
age:= 41;
end;
procedure father.talk;
begin
write ('????');
end;
constructor son.init;
begin
age:= 14;
girlfriend:= 2;
end;
procedure son.talk;
begin
write ('!!!!!');
end;
begin
clrscr;
sergei.init;
anton.init;
link:= @sergei;
link^.talk;
Readln;
link:= @anton;
link^.talk;
readln;
end.
:
1. - .
2. .
3. - .
.