Einzelnen Beitrag anzeigen

Benutzerbild von Aurelius
Aurelius

Registriert seit: 29. Jan 2007
Ort: Erfurt
753 Beiträge
 
Delphi 7 Personal
 
#61

Re: Ratezahl 2 Delphi (leicht)

  Alt 2. Nov 2007, 15:01
So könnte es aussehen. recht übersichtlich...

Delphi-Quellcode:
procedure TForm1.Vergleiche(Sender: TObject);
begin
 count := count + 1;
 Label4.Caption := IntToStr( count);
 if count = 10 then
 begin
  Label4.Caption := 'Maximale Rateanzahl erreicht, die Lösung ist: , Neue runde?';
  BRaten.Enabled := false ;
  Label7.Caption := IntToStr ( Zahl);
 end;

 if StrToInt(EEingabe.Text) > Zahl then
 begin
  PAntwort.Caption := 'zu groß';
  PAntwort.Color := clred;
  if (abs(zahl - StrtoInt (Eeingabe.Text)) > 0) and (abs(zahl - StrtoInt (Eeingabe.Text)) < 5) then
  PAntwort.caption := 'Du bist ganz nah dran, aber die Zahl ist zu groß!else
  if (abs(zahl - StrtoInt (Eeingabe.Text)) > 5) and (abs(zahl - StrtoInt (Eeingabe.Text)) < 15) then
  PAntwort.caption := 'Es wird wärmer, aber noch ist die Zahl zu groß...';
 end;

 if StrToInt (EEingabe.Text) < Zahl then
 begin
  PAntwort.Caption := 'Zu klein' ;
  PAntwort.Color := clred;
  if (abs(zahl - StrtoInt (Eeingabe.Text)) > 0) and (abs(zahl - StrtoInt (Eeingabe.Text)) < 5) then
  PAntwort.caption := 'Du bist ganz nah dran, aber die Zahl ist noch etwas zu klein!else
  if (abs(zahl - StrtoInt (Eeingabe.Text)) > 5) and (abs(zahl - StrtoInt (Eeingabe.Text)) < 15) then
  PAntwort.caption := 'Es wird wärmer, aber noch ist die Zahl zu klein...';
 end;

 if StrToInt (EEingabe.Text) = Zahl then
 begin
  PAntwort.Caption := 'Richtig!';
  PAntwort.Color := cllime;
  Label6.Caption := 'Ihr habt gewonnen!!! Probiert es gleich nochmal';
 end;
end;
Jonas
  Mit Zitat antworten Zitat