Объектно-ориентированное программирование. Модуль Graph, страница 8

begin

Write('Введите искомый табельный номер: ');

ReadLn(answ);

now:=first;

f:=true;

while now<>nil do begin

if now^.data.tabnum=answ then begin

if f then begin

f:=false;

first:=now;

now^.pred:=nil;

last:=now end

else begin

last^.next:=now;

last:=now;

end;

end;

now:=now^.next

end;

if f then first:=nil

else last^.next:=nil;

end;

end.


GRAFIKA.PAS

unit grafika;

interface

uses crt,graph;

procedure zastavka;

implementation

procedure zastavka;

const

detect=0;

{For ball}

r=3;

d=r*2;

{For speed}

pause=1000;

var

dr,m,error,maxx,maxy,SizeOfBall,

x1,y1,dx1,dy1,x2,y2,dx2,dy2,x1P,x2P,x3P,y1P,y2P:integer;

choose:char;

f:boolean;

ball1,ball2:Pointer;

st1:string;

begin

{General}

dr:=detect;

InitGraph(dr,m,'');

error:=GraphResult;

if error<> grOk then begin

WriteLn(GraphErrorMsg(error));

readkey;

exit

end;

maxX:=GetMaxX div 2;

maxY:=GetMaxY div 2;

Randomize;

{_General}

{Make Text}

SetTextStyle(1,HorizDir,3);

SetColor(10);

st1:='Kursovay''a rabota Suhodoeva Pavla I-351';

x1:=(GetMaxX div 2)-(textWidth(st1) div 2);

OutTextXY(x1,GetMaxY div 8,st1);

SetTextStyle(2,HorizDir,4);

SetColor(9);

st1:='For exit press ''Esc''';

x1:=(GetMaxX div 2)-(textWidth(st1) div 2);

OutTextXY(x1,(GetMaxY div 8)*7,st1);

SetColor(7);

{_Make Text}

{Make Game Zone}

x1:=maxx div 2;

y1:=maxy div 2;

Rectangle(x1,y1,MaxX+x1,MaxY+y1);

SetViewPort(x1+1,1+y1,x1+MaxX-1,y1+MaxY-1,ClipOn);

x2:=x1 div 3;

y2:=y1 div 3;

x1P:=x1-x2;

x2P:=x1;

x3P:=x1+x2;

y1P:=y1-y2;

y2P:=y1+y2;

Line(x1P,y1P,x1P,y2P);

Line(x2P,y1P,x2P,y2P);

Line(x3P,y1P,x3P,y2P);

{_Make Game Zone}

{Make table and balls and put them into heap}

{Ball1}

x1:=10; y1:=10;

SetColor(14);

SetFillStyle(1,14);

Circle(x1+r,y1+r,r);

dx1:=x1+d; dy1:=y1+d;

FloodFill(x1+r,y1+r,14);

SizeOfBall:=ImageSize(x1,y1,dx1,dy1);

GetMem(Ball1,SizeOfBall);

GetImage(x1,y1,dx1,dy1,Ball1^);

PutImage(x1,y1,Ball1^,XorPut);

{_Ball1}

{Ball2}

x1:=10; y1:=10;

SetColor(9);

SetFillStyle(1,9);

Circle(x1+r,y1+r,r);

dx1:=x1+d; dy1:=y1+d;

FloodFill(x1+r,y1+r,9);

GetMem(Ball2,SizeOfBall);

GetImage(x1,y1,dx1,dy1,Ball2^);

PutImage(x1,y1,Ball2^,XorPut);

{_Ball2}

{_Make table and balls and put them into heap}

{Set first coordinates of toys}

dx1:=(maxy div 2)-r;

x1:=(maxx div 4)-r;

y1:=dx1;

x2:=(maxx div 4)*3-r;

y2:=dx1;

dx1:=random(4)+1;

dy1:=random(3)+1;

dx2:=random(3)+1;

dy2:=random(3)+1;

{_Set first coordinates of toys}

{Main Repeating}

repeat

PutImage(x1,y1,Ball1^,XorPut);

PutImage(x2,y2,Ball2^,XorPut);

Delay(pause);

PutImage(x1,y1,Ball1^,XorPut);

PutImage(x2,y2,Ball2^,XorPut);

{New Coordinates}

{Speed: 1..3}

x1:=x1+dx1;

y1:=y1+dy1;

x1:=x1+dx1;

y1:=y1+dy1;

x2:=x2+dx2;

y2:=y2+dy2;

x2:=x2+dx2;

y2:=y2+dy2;

if KeyPressed then begin

choose:=readkey;

if choose=#0 then choose:=readkey;

if choose=#27 then begin   {Esc}

closeGraph;

exit

end;

end;

if (x1<=4)or((x1+d-4)>=maxx) then dx1:=-dx1;

f:=(y1+d>=y1P)and(y1<=y2P);

if f and (

((x1+d>=x1P) and (x1<=x1P))or

((x1+d>=x2P) and (x1<=x2P))or

((x1+d>=x3P) and (x1<=x3P))) then dx1:=-dx1;

if (x2<=4)or((x2+d-4)>=maxx) then dx2:=-dx2;

f:=(y2+d>=y1P)and(y2<=y2P);

if f and (

((x2+d>=x1P) and (x2<=x1P))or

((x2+d>=x2P) and (x2<=x2P))or

((x2+d>=x3P) and (x2<=x3P))) then dx2:=-dx2;

if (y1<=4)or((y1+d-4)>=maxy) then dy1:=-dy1;

if (y2<=4)or((y2+d-4)>=maxy) then dy2:=-dy2;

if ((y1+d>=y2)and(y1<=y2+d))and

((x1+d>=x2)and(x1<=x2+d)) then begin

dx1:=random(4); dy1:=random(4);

dx2:=random(4); dy2:=random(4);

if (dx1=0)and(dx2=0) then dx1:=2;

if (dy1=0)and(dy2=0) then dy1:=2;

if random(2)=1 then begin

dx2:=-dx2;

dy1:=-dy1;

end

end;

until false;

end;

end.


Результаты.

Главное меню:

Результаты работы модуля «работа с массивом»:

Результаты работы модуля «работа с матрицей»:

Результаты работы модуля «работа со связанным списком»:

Зазтавка: