Delphi-PRAXiS
Seite 4 von 7   « Erste     234 56     Letzte »    

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)

andiak 1. Nov 2007 22:19

Re: Ratezahl 2 Delphi (leicht)
 
ok hab ich dieser button mit wo "Rate" draufsteht besitzt jetzt folgendes:

procedure TForm1.Vergleiche(Sender: TObject);
begin
count := count + 1;
Label4.Caption := IntToStr( count);
if count = 10 then
Label4.Caption := 'Maximale Rateanzahl erreicht, Neue runde?';
BRaten.Enabled := false
end;

if StrToInt(EEingabe.Text) > Zahl then
begin
PAntwort.Caption := 'zu groß!';
PAntwort.Color := clred
end;
begin
if StrToInt (EEingabe.Text) < Zahl then
begin
PAntwort.Caption := 'zu klein';
PAntwort.Color := clred
end;
begin
if StrToInt (EEingabe.Text) = Zahl then
PAntwort.Caption := 'Richtig!';
PAntwort.Color := clgreen
end
// Dies ist ein Kommentar.
// Einrückungen verdeutlichen Abhängigkeiten zwischen Anweisungen
// und machen den Programm-Code besser lesbar.
end;



allerdings kommt jetzt ein fehler bei:
if StrToInt(EEingabe.Text) > Zahl then


Deklaration erwartet aber if gefunden

was habe ich falsch gemacht

mkinzler 2. Nov 2007 05:33

Re: Ratezahl 2 Delphi (leicht)
 
Füge ein begin nach
Delphi-Quellcode:
if count = 10 then
ein

andiak 2. Nov 2007 09:18

Re: Ratezahl 2 Delphi (leicht)
 
danke... das hab ich jetzt das funktioniert...

Ich weiß das ich etwas bei form1.oncreate
einfügen muss damit die Random immer anders ist nur welches befehl?

Außerdem brauch ich jetzt ein button der alles zurück setzt für ein neues spiel könnt ihr mir da eventuell denkanstöße geben?

mkinzler 2. Nov 2007 09:22

Re: Ratezahl 2 Delphi (leicht)
 
Delphi-Quellcode:
Randomize;

andiak 2. Nov 2007 09:27

Re: Ratezahl 2 Delphi (leicht)
 
eine frage noch außer das mit dem Button für neues spiel
warum wird mein PAntwort Button immer grün auch wenn die zahl zu groß oder zu klein ist normalerweiße sollte er nur grün werden wenn die iengegebene Zahl richtig ist:

if StrToInt(EEingabe.Text) > Zahl then
begin
PAntwort.Caption := 'zu groß!';
PAntwort.Color := clred
end;
begin
if StrToInt (EEingabe.Text) < Zahl then
begin
PAntwort.Caption := 'zu klein';
PAntwort.Color := clred
end;
begin
if StrToInt (EEingabe.Text) = Zahl then
PAntwort.Caption := 'Richtig!';
PAntwort.Color := cllime
end

mkinzler 2. Nov 2007 09:32

Re: Ratezahl 2 Delphi (leicht)
 
Es waren zu viele begins bzw. an der falschen Stelle. Das Setzen der farbe grün wurde deshalb immer ausgeführt.

Delphi-Quellcode:
if StrToInt(EEingabe.Text) > Zahl then
begin
    PAntwort.Caption := 'zu groß!';
    PAntwort.Color := clred
end;
if StrToInt (EEingabe.Text) < Zahl then
begin
    PAntwort.Caption := 'zu klein';
    PAntwort.Color := clred
end;
if StrToInt (EEingabe.Text) = Zahl then
begin
    PAntwort.Caption := 'Richtig!';
    PAntwort.Color := cllime
end;

andiak 2. Nov 2007 09:47

Re: Ratezahl 2 Delphi (leicht)
 
Ok thanks das habe ich jetzt
hinbekommen genauso mit dem darstellen der richtigen zahl bei 10 falschen versuchen

Label7.Caption := IntToStr ( Zahl);

Gibt es ein befehl welcher sagt dass, das Programm kommplet neu geladen werden soll? für "Neues Spiel"

mkinzler 2. Nov 2007 09:52

Re: Ratezahl 2 Delphi (leicht)
 
Warum das es reicht doch alle Ausgabe die Eingabe und die Zählervariable zurückzusetzen und eine neue Zufallszahl zu ermitteln.

andiak 2. Nov 2007 09:58

Re: Ratezahl 2 Delphi (leicht)
 
ich hab dort jetzt folgendes stehen bei Onclick beim "Neues SPiel" button


count := 0;
BRaten.Enabled := true ;
Label4.Caption := '' ;
Zahl := Random(100);
ScrollBar.Position := Zahl


irgendwie klappt es abe rnoch net

mkinzler 2. Nov 2007 10:09

Re: Ratezahl 2 Delphi (leicht)
 
Was klappt nicht?


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:18 Uhr.
Seite 4 von 7   « Erste     234 56     Letzte »    

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