1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Memo1: TMemo; Button2: TButton; Button3: TButton; Label2: TLabel; Label3: TLabel; Label1: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Memo2: TMemo; Label8: TLabel; procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private public Versuchsliste:TStringlist; end;
var Form1: TForm1;
implementation
{$R *.DFM}
Var Zufall,Versuche,Eingabe,Zaehler:integer; Endzeit,Anfangszeit:integer; Bitmap: TBitmap;
procedure TForm1.FormCreate(Sender: TObject); begin Versuchsliste:=TStringlist.Create; end;
procedure TForm1.Button1Click(Sender: TObject); begin
Eingabe:=strToInt(Edit1.text); Versuchsliste.Add(Format('%d.Eingabe:',[Versuche+1])+Edit1.Text);
If Eingabe<Zufall then label1.Caption:='Zu klein';
If Eingabe>Zufall then label1.Caption:='Zu Groß';
If Eingabe=Zufall then begin label1.Caption:='Richtig'; Endzeit:=GetTickCount; memo2.Text:=floattostr((Endzeit-Anfangszeit)/1000); end; If Eingabe<>Zufall then Versuche:=Versuche+1;
If Eingabe=Zufall then Versuche:=Versuche+1;
begin Versuchsliste.SaveToFile('Eingaben.txt'); end;
If Eingabe<0 then ShowMessage('Die Zahl muss größer oder gleich null sein!');
If Eingabe>100 then ShowMessage('Die Zahl muss kleiner oder gleich hundert sein!');
Memo1.Text:=inttostr(Versuche);
end;
procedure TForm1.Button3Click(Sender: TObject); var Bitmap: TBitmap; Dateinamen:array[1..3]of string; begin Bitmap := TBitmap.Create; Dateinamen[3]:='Projekt.bmp'; Dateinamen[2]:='Projekt 2.bmp'; Dateinamen[1]:='Projekt 3.bmp';
try for Zaehler:=3 downto 1 do begin Bitmap.LoadFromFile(Dateinamen[Zaehler]); Form1.Canvas.Brush.Bitmap := Bitmap; Form1.Canvas.FillRect(Rect(0,0,300,200)); Sleep(2000); Form1.Canvas.Brush.Bitmap := nil; end; finally Form1.Canvas.Brush.Bitmap := nil; Bitmap.Free; end; end;
procedure TForm1.Button2Click(Sender: TObject); begin Anfangszeit:=GetTickCount; Versuche:=0; randomize; Zufall:=random(100)+1; end;
end. |