Unit constr; Interface uses crt,graph; type TPosition = (_goalkeeper, _defender, _midfielder, _forward); TPeople = object age: integer; name: string; constructor init(AName: string; AnAge: integer); end; PTFootballer = ^TFootballer; PTReferee = ^TReferee; PTteam= ^TTeam; TFootballer = object(TPeople) code_position: TPosition; code_team: integer; k: byte; constructor init(AName: string; AnAge: integer; team, position: string; Ak: byte); procedure print_info(i:integer); { function Raschet:word;} end; TReferee = object(TPeople) s1,s2:byte; end; PStrategy = ^TStrategy; TStrategy = object constructor init; destructor done; virtual; procedure Play; virtual; end; PTAttackStrategy = ^TAttackStrategy; TAttackStrategy = object(TStrategy) constructor init; procedure Play; virtual; end; PTDefendStrategy = ^TDefendStrategy; TDefendStrategy = object(TStrategy) constructor init; procedure Play; virtual; end; TTeam = object code_team: integer; squad: array[1 .. 20] of PTFootballer; moneys:word; constructor init(team: string); { destructor done; procedure SetStrategy(s:PStrategy); procedure Run;} procedure Koef; procedure changes; private players: integer; str:PStrategy; procedure squad_print; end; Type Ta=array[1..10]of string; TPlayzone=object team_list:array[1..10] of PTteam; squad_ref:array[1..5] of PTReferee; procedure Start; procedure Ballmenu(x1,y1:Word;n:byte;A:Ta;u,u1:boolean;S:string;Var pos1:byte); procedure Menu(x1,y1:Word;n:byte;A:Ta;u,u1:boolean;S:string;Var pos1:byte); end; const savef='save.txt'; s_position: array[TPosition] of string = ('GK', 'DF', 'MD', 'F'); max_teams = 5; s_team: array[1 .. max_teams] of string = ( 'cska', 'man.united', 'spartak', 'zenit', 'barcelona' ); var A,st:Ta; gm,gd:integer; pos1,pos2:byte; u,u1:boolean; S:string; {label 11;} team: TTeam; playzone:TPlayzone; i,players: integer; procedure init_footballers(const filename: string); procedure printer; Implementation constructor TPeople.init(AName: string; AnAge: integer); begin age := AnAge; name := AName; end; constructor TFootballer.init(AName: string; AnAge: integer; team, position: string; Ak: byte); var p: TPosition; i,ik: integer; begin inherited init(AName, AnAge); for p := low(Tposition) to high(TPosition) do if s_position[p] = position then begin code_position := p; end; for i := 1 to max_teams do if s_team[i] = team then begin code_team := i; end; k := Ak; end; procedure TFootballer.print_info; begin writeln(i:2, s_position[code_position]:10, name:18, k:4, ' (',age:2,')' ) end; const max_footballers = 100; var count_footballers: integer; footb_array: array[1 .. max_footballers] of PTFootballer; procedure init_footballers(const filename: string); function _toint(s: string): integer; var _result, _error: integer; begin val(s, _result, _error); _toint := _result; end; function _copy(var s: string; count: integer): string; begin _copy := copy(s, 1, pred(count)); delete(s, 1, count); end; var f: text; s: string; f_n, f_t, f_p: string; f_a, f_c: integer; begin assign(f, filename); reset(f); count_footballers := 0; while not seekeof(f) do begin inc(count_footballers); readln(f, s); f_n := _copy(s, pos(' ', s)); f_a := _toint(_copy(s, pos(' ', s))); f_t := _copy(s, pos(' ', s)); f_p := _copy(s, pos(' ', s)); f_c := _toint(s); new( footb_array[count_footballers], init(f_n, f_a, f_t, f_p, f_c) ); end; close(f); end; constructor TTeam.init(team: string); var i: integer; begin for i := 1 to max_teams do if s_team[i] = team then begin code_team := i; end; players := 0; for i := 1 to count_footballers do begin if footb_array[i]^.code_team = code_team then begin inc(players); squad[players] := footb_array[i]; end; end; end; procedure TTeam.squad_print; var i: integer; begin for i := 1 to 11 do squad[i]^.print_info(i); writeln('-------------------------------------------'); for i := 12 to players do squad[i]^.print_info(i); end; procedure printer; begin closegraph; team.squad_print; end; procedure TTeam.changes; var f,sec,secv: byte; k:char; begin repeat write('First player: '); readln(f); write('Second player: '); readln(sec); clrscr; secv:=70; squad[secv]:=squad[f]; squad[f]:=squad[sec]; squad[sec]:=squad[secv]; team.koef; team.squad_print; write('Continue ? [Y/N] ');readln(k); writeln; until(k='n') or (k='N'); end; {function TFootballer.Raschet(age,k:byte):word; var price:word; begin if k<30 then price:=k*5 else if k<50 then price:=k*30 else if k<80 then price:=k*70 else price:=k*210; if age<=22 then price:=trunc(price+price/10); end;} constructor TStrategy.init; begin end; destructor TStrategy.done; begin end; procedure TStrategy.Play; begin end; constructor TAttackStrategy.init; begin inherited init; end; procedure TAttackStrategy.Play; begin writeln('attacking'); end; constructor TDefendStrategy.init; begin inherited init; end; procedure TDefendStrategy.Play; begin writeln('defending'); end; Procedure TPlayzone.BallMenu(x1,y1:Word;n:byte;A:Ta;u,u1:boolean;S:string;Var pos1:byte); Var i:byte; x,y:Word; Key:char; Begin if u=true then begin ClearDevice; end; setfillstyle(1,1); rectangle(0,0,640,480); floodfill(1,1,1); setcolor(0); circle(226,223,181); SetFillstyle(1,15); FloodFill(267,187,0); line(84,214,136,176); line(136,176,200,214); line(200,214,200,294); line(200,294,141,322); line(141,322,88,285); line(88,285,84,214); line(84,214,50,179); line(88,285,62,299); line(141,322,150,374); line(150,374,207,403); line(150,374,132,378); line(207,403,259,382); line(259,382,264,329); line(259,382,294,391); line(200,294,264,329); line(264,329,330,292); line(330,292,368,314); line(368,314,359,345); line(368,314,396,284); line(407,218,378,185); line(378,185,333,217); line(333,217,267,177); line(267,177,200,214); line(267,177,267,103); line(267,103,316,87); line(316,87,316,66); line(316,87,366,127); line(366,127,375,120); line(330,292,333,217); line(378,185,366,127); line(136,176,145,109); line(145,109,206,75); line(206,75,206,43); line(102,92,145,109); line(206,75,267,103); Setfillstyle(1,0); FloodFill(136,186,0); FloodFill(316,110,0); FloodFill(330,340,0); Floodfill(200,60,0); FloodFill(150,376,0); settextstyle(1,0,5); Outtextxy(420,120,'FOOTBALL'); Outtextxy(422,120,'FOOTBALL'); Outtextxy(424,120,'FOOTBALL'); Outtextxy(426,120,'FOOTBALL'); Outtextxy(420,170,'MANAGER'); Outtextxy(422,170,'MANAGER'); Outtextxy(424,170,'MANAGER'); Outtextxy(426,170,'MANAGER'); settextstyle(0,0,1); setcolor(14); outtextxy(523,220,'version 1.0'); settextstyle(0,0,1); if u1=true then begin Outtextxy(x1,y1+3,S); Rectangle(x1-1,y1-1,x1+121,y1+11*(n+1)); y1:=y1+11; end; Setbkcolor(0); Setcolor(11); if u1=false then begin Rectangle(x1-1,y1-1,x1+121,y1+11*n); end; x:=x1; y:=y1; SetFillStyle(1,1); Bar(x,y,x+120,y+10); SetFillStyle(1,1); y:=y+11; for i:=2 to n do begin Bar(x,y,x+120,y+10); y:=y+11; end; x:=x1; y:=y1; Outtextxy(x,y+3,A[1]); y:=y+11; Setcolor(11); for i:=2 to n do begin Outtextxy(x,y+3,A[i]); y:=y+11; end; pos1:=1; x:=x1; y:=y1; Repeat key:=readkey; if Ord(key)=0 then begin SetFillStyle(1,1); Bar(x,y,x+120,y+10); SetFillStyle(1,8); Setcolor(11); Outtextxy(x,y+3,A[pos1]); key:=readkey; if Ord(Key)=72 then begin if pos1=1 then begin pos1:=n; y:=y+11*(n-1); Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end else begin pos1:=pos1-1; y:=y-11; Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end; end; if Ord(Key)=80 then begin if pos1=n then begin pos1:=1; y:=y-11*(n-1); Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end else begin pos1:=pos1+1; y:=y+11; Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end; end; end; Until Ord(Key)=13; if u=true then begin ClearDevice; end; end; {---------------------------------------------} Procedure TPlayzone.Menu(x1,y1:Word;n:byte;A:Ta;u,u1:boolean;S:string;Var pos1:byte); Var i:byte; x,y:Word; Key:char; Begin if u=true then begin ClearDevice; end; setfillstyle(1,1); rectangle(0,0,640,480); floodfill(1,1,1); settextstyle(0,0,1); if u1=true then begin Outtextxy(x1,y1+3,S); Rectangle(x1-1,y1-1,x1+121,y1+11*(n+1)); y1:=y1+11; end; Setbkcolor(0); Setcolor(11); if u1=false then begin Rectangle(x1-1,y1-1,x1+121,y1+11*n); end; x:=x1; y:=y1; SetFillStyle(1,1); Bar(x,y,x+120,y+10); SetFillStyle(1,1); y:=y+11; for i:=2 to n do begin Bar(x,y,x+120,y+10); y:=y+11; end; x:=x1; y:=y1; Outtextxy(x,y+3,A[1]); y:=y+11; Setcolor(11); for i:=2 to n do begin Outtextxy(x,y+3,A[i]); y:=y+11; end; pos1:=1; x:=x1; y:=y1; Repeat key:=readkey; if Ord(key)=0 then begin SetFillStyle(1,1); Bar(x,y,x+120,y+10); SetFillStyle(1,8); Setcolor(11); Outtextxy(x,y+3,A[pos1]); key:=readkey; if Ord(Key)=72 then begin if pos1=1 then begin pos1:=n; y:=y+11*(n-1); Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end else begin pos1:=pos1-1; y:=y-11; Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end; end; if Ord(Key)=80 then begin if pos1=n then begin pos1:=1; y:=y-11*(n-1); Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end else begin pos1:=pos1+1; y:=y+11; Bar(x,y,x+120,y+10); Setcolor(10); Outtextxy(x,y+3,A[pos1]); end; end; end; Until Ord(Key)=13; if u=true then begin ClearDevice; end; end; procedure TPlayzone.start; begin end; procedure Tteam.Koef; var i:byte; sumk,teamk:integer; begin {for i:=1 to 11 do sumk:=0; sumk:=sumk+codek; teamk:=trunc(sumk/11); writeln('TEAM KOEF: ',sumk);} end; end.