unit Unit1;
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
CheckBox1: TCheckBox;
Panel1: TPanel;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
const
Max = 100;
var
Form1: TForm1;
Frage:
Array [1 .. Max]
of String;
Antwort:
Array [1 .. Max, 1 .. 3]
of String;
Richtig:
Array [1 .. Max]
of Integer;
Nr: Integer;
Datei: TextFile;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
if RadioGroup1.ItemIndex = Richtig[Nr] - 1
then
Panel1.Caption := '
Richtig!'
else
Panel1.Caption := '
Falsch!'
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Nr := random(Max) + 1;
Panel1.Caption := Frage[Nr];
RadioGroup1.Items[0] := Antwort[Nr, 1];
RadioGroup1.Items[1] := Antwort[Nr, 2];
RadioGroup1.Items[2] := Antwort[Nr, 3];
if CheckBox1.Checked
then
RadioGroup1.ItemIndex := Richtig[Nr] - 1
else
RadioGroup1.ItemIndex := -1;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
Zeile:
String;
begin
randomize;
AssignFile(Datei, '
DelphiVokabeln.txt');
Reset(Datei);
for i := 1
To Max
do
begin
ReadLn(Datei, Frage[i]);
ReadLn(Datei, Antwort[i, 1]);
ReadLn(Datei, Antwort[i, 2]);
ReadLn(Datei, Antwort[i, 3]);
ReadLn(Datei, Zeile);
Richtig[i] := StrToInt(Zeile);
end;
end;
end.