unit unit_1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, ExtCtrls; type TForm1 = class(TForm) spielplan1: TStringGrid; spielplan2: TStringGrid; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button2: TButton; Edit4: TEdit; Timer1: TTimer; Edit5: TEdit; Edit6: TEdit; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } anzdoppel:integer; end; const mannschaftenmax = 4; var Form1: TForm1; implementation {$R *.dfm} procedure vergleichen ();forward; procedure TForm1.FormCreate(Sender: TObject); begin spielplan1.Rows[0].Strings[0] := '1'; spielplan1.Rows[0].Strings[1] := '2'; spielplan1.Rows[1].Strings[0] := '1'; spielplan1.Rows[1].Strings[1] := '3'; spielplan1.Rows[2].Strings[0] := '1'; spielplan1.Rows[2].Strings[1] := '4'; spielplan1.Rows[3].Strings[0] := '2'; spielplan1.Rows[3].Strings[1] := '3'; spielplan1.Rows[4].Strings[0] := '2'; spielplan1.Rows[4].Strings[1] := '4'; spielplan1.Rows[5].Strings[0] := '3'; spielplan1.Rows[5].Strings[1] := '4'; anzdoppel := 0; //vergleichen(); end; procedure spieletauschen (spiel1 : integer ; spiel2 : integer); var i : integer; begin for i:=0 to 5 do begin form1.spielplan2.rows[i].strings[0] := form1.spielplan1.rows[i].strings[0]; form1.spielplan2.rows[i].strings[1] := form1.spielplan1.rows[i].strings[1]; end; form1.spielplan2.Rows[spiel1].Strings[0] := form1.spielplan1.Rows[spiel2].Strings[0]; form1.spielplan2.Rows[spiel1].Strings[1] := form1.spielplan1.Rows[spiel2].Strings[1]; form1.spielplan2.Rows[spiel2].Strings[0] := form1.spielplan1.Rows[spiel1].Strings[0]; form1.spielplan2.Rows[spiel2].Strings[1] := form1.spielplan1.Rows[spiel1].Strings[1]; end; procedure vergleichen (); var i : integer; begin for i := 0 to 4 do begin if form1.spielplan2.Rows[i].Strings[0] = form1.spielplan2.rows[i+1].Strings[0] then begin form1.anzdoppel := form1.anzdoppel +1 end; if form1.spielplan2.Rows[i].Strings[1] = form1.spielplan2.rows[i+1].Strings[1] then begin form1.anzdoppel := form1.anzdoppel +1 end; if form1.spielplan2.Rows[i].Strings[0] = form1.spielplan2.rows[i+1].Strings[1] then begin form1.anzdoppel := form1.anzdoppel +1 end; if form1.spielplan2.Rows[i].Strings[1] = form1.spielplan2.rows[i+1].Strings[0] then begin form1.anzdoppel := form1.anzdoppel +1 end; end; form1.Edit3.text := inttostr(form1.anzdoppel); if form1.Edit3.text <= form1.Edit4.text then begin form1.Edit4.text := form1.Edit3.text; for i:=0 to 5 do begin form1.spielplan1.rows[i].strings[0] := form1.spielplan2.rows[i].strings[0]; form1.spielplan1.rows[i].strings[1] := form1.spielplan2.rows[i].strings[1]; end; end; end; procedure TForm1.Timer1Timer(Sender: TObject); begin form1.anzdoppel := 0; randomize; edit1.text := inttostr(random(6)); repeat edit2.text := inttostr(random(6)); until edit1.text <> edit2.text; spieletauschen(strtoint(edit1.text),strtoint(edit2.Text)); vergleichen(); end; procedure TForm1.Button2Click(Sender: TObject); begin timer1.Enabled := not timer1.Enabled; end; end.