Delphi-PRAXiS
Seite 7 von 7   « Erste     567   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Ratezahl 2 Delphi (leicht) (https://www.delphipraxis.net/102653-ratezahl-2-delphi-leicht.html)

Aurelius 2. Nov 2007 15:01

Re: Ratezahl 2 Delphi (leicht)
 
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:46 Uhr.
Seite 7 von 7   « Erste     567   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz