unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TVokabeltrainer =
class(TForm)
l_frage: TLabel;
l_checkup: TLabel;
l_antwort: TLabel;
b_submit: TButton;
b_next: TButton;
b_cheat: TButton;
b_text: TButton;
OpenDialog1: TOpenDialog;
ListBox1: TListBox;
l_loesung: TEdit;
RadioGroup1: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure b_submitClick(Sender: TObject);
procedure b_nextClick(Sender: TObject);
procedure b_cheatClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
const
max=8;
var
Vokabeltrainer: TVokabeltrainer;
datei: TextFile;
DateiName:
string;
a_vok:
Array of String;
a_antwort:
Array of String;
a_richtig:
Array of Integer;
nr: Integer;
voc: TStringList;
implementation
{$R *.DFM}
procedure TVokabeltrainer.FormCreate(Sender: TObject);
var max: integer;
begin
If OpenDialog1.execute
then
Dateiname:=opendialog1.filename
else
Dateiname:='
voc.txt';
voc:=TStringlist.create;
voc.LoadFromFile(Dateiname);
max:=voc.count
div(5);
nr:=random(max-1);
l_frage.caption:='
Vokabel: ' + voc[nr*5];
radiogroup1.items[0]:=voc[nr*5+1];
radiogroup1.items[1]:=voc[nr*5+2];
radiogroup1.items[2]:=voc[nr*5+3];
nr:=random(max)+1;
l_frage.caption:='
Vokabel: ' + a_vok[nr*5];
radiogroup1.items[0]:=a_antwort[nr*5+1];
radiogroup1.items[1]:=a_antwort[nr*5+2];
radiogroup1.items[2]:=a_antwort[nr*5+3];
radiogroup1.itemindex:=-1;
end;
procedure TVokabeltrainer.b_cheatClick(Sender: TObject);
begin
l_checkup.caption:='
how about "' + a_antwort[nr, a_richtig[nr]] + '
"?';
l_checkup.font.color:=clblack;
l_checkup.font.size:=10;
end;
procedure TVokabeltrainer.b_submitClick(Sender: TObject);
begin
If (Radiogroup1.itemindex=-1)
and (l_loesung.text='
')
then
begin
l_checkup.caption:='
Bitte eine Auswahl treffen';
l_checkup.font.color:=clblack;
end
else
If (Radiogroup1.itemindex=a_richtig[nr]-1)
or (l_loesung.text=a_antwort[nr, a_richtig[nr]] )
then
begin
l_checkup.caption:='
Richtig!';
l_checkup.font.color:=clgreen;
end
else
begin
l_checkup.caption:='
Falsch!';
l_checkup.font.color:=clred;
end;
end;
procedure TVokabeltrainer.b_nextClick(Sender: TObject);
begin
nr:=random(max)+1;
l_frage.caption:='
Vokabel: ' + a_vok[nr*5];
radiogroup1.items[0]:=a_antwort[nr*5+1];
radiogroup1.items[1]:=a_antwort[nr*5+2];
radiogroup1.items[2]:=a_antwort[nr*5+3];
radiogroup1.itemindex:=-1;
l_checkup.caption:='
';
l_loesung.Text:='
';
end;
end.