Informatik Material Portal Portfolio Präsentation Grafik Tabellenkalkulation Informatik56 9 10 11 12 13 Messen, Steuern, Regeln Linux Theorie Didaktik Open Source Spiele Wettbewerbe Netzbetreuung intern Literatur Links Energie corewar UNIX/Linux
Pfad: Startseite / Fächer / Informatik
Autor: be
21.09.2005 10:48
412

Gedächtnistraining Eingabe - Lösung

unit mGedaechtnistraining;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    edZahlen: TEdit;
    Memo1: TMemo;
    lbAntwort: TLabel;
    btOK: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure btOKClick(Sender: TObject);
  private
    { Private-Deklarationen }
    zahlen: Array[1..5] of Integer;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Randomize;
  for i:=1 to 5 do
  begin
    zahlen[i] := Random(101);
    edZahlen.Text := edZahlen.Text + ' ' + IntToStr(zahlen[i]);
  end;
end;

procedure TForm1.btOKClick(Sender: TObject);
var fehler: Boolean;
    i: Integer;
begin
  fehler := False;
  for i:=1 to 5 do
    if StrToInt(Memo1.Lines[i-1]) <> zahlen[i] then
      fehler := True;
  if fehler=False then
    lbAntwort.Caption := 'Richtig!'
  else
    lbAntwort.Caption := 'Falsch!';

  { oder:
  if (StrToInt(Memo1.Lines[0]) = zahlen[1]) and
     (StrToInt(Memo1.Lines[1]) = zahlen[2]) and
     (StrToInt(Memo1.Lines[2]) = zahlen[3]) and
     (StrToInt(Memo1.Lines[3]) = zahlen[4]) and
     (StrToInt(Memo1.Lines[4]) = zahlen[5])
  then
    lbAntwort.Caption := 'Richtig!'
  else
    lbAntwort.Caption := 'Falsch!'; }
end;

end.