unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm2 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
GroupBox1: TGroupBox;
Button11: TButton;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Gewinner;
procedure Button10Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
//Buttons
procedure TForm2.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button1.Caption:='
X';
Button1.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button1.Caption:='
O';
Button1.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button2.Caption:='
X';
Button2.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button2.Caption:='
O';
Button2.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button3.Caption:='
X';
Button3.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button3.Caption:='
O';
Button3.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button4.Caption:='
X';
Button4.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button4.Caption:='
O';
Button4.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button5.Caption:='
X';
Button5.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button5.Caption:='
O';
Button5.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button6.Caption:='
X';
Button6.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button6.Caption:='
O';
Button6.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button7.Caption:='
X';
Button7.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button7.Caption:='
O';
Button7.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button8.Caption:='
X';
Button8.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button8.Caption:='
O';
Button8.Enabled:=False;
end;
Gewinner;
end;
procedure TForm2.Button9Click(Sender: TObject);
begin
if RadioButton1.Checked=True
then
begin
Button9.Caption:='
X';
Button9.Enabled:=False;
end;
if RadioButton2.Checked=True
then
begin
Button9.Caption:='
O';
Button9.Enabled:=False;
end;
Gewinner;
end;
//Gewinner
procedure TForm2.Gewinner;
begin
//Kombi1
if (Button1.Caption='
X')
and (Button2.Caption='
X')
and (Button3.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button1.Caption='
O')
and (Button2.Caption='
O')
and (Button3.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi2
if (Button4.Caption='
X')
and (Button5.Caption='
X')
and (Button6.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button4.Caption='
O')
and (Button5.Caption='
O')
and (Button6.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi3
if (Button7.Caption='
X')
and (Button8.Caption='
X')
and (Button9.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button7.Caption='
O')
and (Button8.Caption='
O')
and (Button9.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi4
if (Button1.Caption='
X')
and (Button4.Caption='
X')
and (Button7.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button1.Caption='
O')
and (Button4.Caption='
O')
and (Button7.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi5
if (Button2.Caption='
X')
and (Button5.Caption='
X')
and (Button8.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button2.Caption='
O')
and (Button5.Caption='
O')
and (Button8.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi6
if (Button3.Caption='
X')
and (Button6.Caption='
X')
and (Button9.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button3.Caption='
O')
and (Button6.Caption='
O')
and (Button9.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi6
if (Button1.Caption='
X')
and (Button5.Caption='
X')
and (Button9.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button1.Caption='
O')
and (Button5.Caption='
O')
and (Button9.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
//Kombi7
if (Button3.Caption='
X')
and (Button5.Caption='
X')
and (Button7.Caption='
X')
then
begin
Label1.Caption:='
Spieler X';
end;
if (Button3.Caption='
O')
and (Button5.Caption='
O')
and (Button7.Caption='
O')
then
begin
Label1.Caption:='
Spieler O';
end;
end;
//New Game
procedure TForm2.Button10Click(Sender: TObject);
begin
Button1.Caption:='
';
Button2.Caption:='
';
Button3.Caption:='
';
Button4.Caption:='
';
Button5.Caption:='
';
Button6.Caption:='
';
Button7.Caption:='
';
Button8.Caption:='
';
Button9.Caption:='
';
Label1.Caption:='
';
end;
//Exit
procedure TForm2.Button11Click(Sender: TObject);
begin
Close;
end;
end.