Delphi-PRAXiS
Seite 2 von 5     12 34     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Timer programmieren (https://www.delphipraxis.net/105306-timer-programmieren.html)

DeddyH 19. Dez 2007 17:25

Re: Timer programmieren
 
In diesem Thread wurden Dir schon einige Lösungsansätze präsentiert.

himitsu 19. Dez 2007 17:35

Re: Timer programmieren
 
dieses wird nur angezeigt wenn alle 6 richtig sind
Delphi-Quellcode:
if richtige = 6 then showmessage ('Sie haben Gewonnen');
und dieses nur wen alle 6 falsch sind.
Delphi-Quellcode:
if falsche = 6 then showmessage ('Sie haben leider verloren');
bei 1 bis 5 Falschen/Richtigen wird nichts angezeigt :stupid:

DeddyH 19. Dez 2007 17:36

Re: Timer programmieren
 
Stimmt, wurde aber auch schon erwähnt, glaube ich ;)

ScrollbarKopf 19. Dez 2007 17:55

Re: Timer programmieren
 
himitsu das bringt sich aber nix er soll ja anzeigen wenn man 1-5 falsche hat das man verloren hat

DeddyH 19. Dez 2007 18:01

Re: Timer programmieren
 
Das ist in Deinem Source aber nicht so.

ScrollbarKopf 19. Dez 2007 18:04

Re: Timer programmieren
 
doch ahb ich doch geschrieben
Delphi-Quellcode:
it Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    Edit12: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
   a,b,c,d,e,f :integer;
   richtige: integer;
   falsche: integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
randomize;
repeat
  a:= random (46);
  b:= random (46);
  c:= random (46);
  d:= random (46);
  e:= random (46);
  f:= random (46);

until(a<>b) and (a<>c) and (a<>d) and (a<>e)
 and (a<>f) and (b<>c) and (b<>d) and (b<>e)
 and (b<>f) and (c<>d) and (c<>e) and (c<>f)
 and (d<>e) and (d<>f) and (e<>f);

edit1.Text := inttostr (a+1);
edit2.Text := inttostr (b+1);
edit3.Text := inttostr (c+1);
edit4.Text := inttostr (d+1);
edit5.Text := inttostr (e+1);
edit6.Text := inttostr (f+1);

richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.clear;
edit2.clear;
edit3.clear;
edit4.clear;
edit5.clear;
edit6.clear;
edit7.clear;
edit8.clear;
edit9.clear;
edit10.clear;
edit11.clear;
edit12.clear;
end;

end

Die Muhkuh 19. Dez 2007 18:04

Re: Timer programmieren
 
Anstatt auf Gleichheit kannst auch Größer als prüfen. ;-)

Und hör auf, jedesmal Deinen Source zu posten...

ScrollbarKopf 19. Dez 2007 18:09

Re: Timer programmieren
 
Ich weiß ent was ihr alle meint ich sage doch das er sagt wenn alle 6 richtig sind soll er sagen gewoonnnen und wenn nur eins falsch ist soll er sagen das man verloren aht

DeddyH 19. Dez 2007 18:10

Re: Timer programmieren
 
Delphi-Quellcode:
richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen')
else showmessage ('Sie haben leider verloren');
Ist kürzer und richtiger.

Zitat:

Zitat von Die Muhkuh
Und hör auf, jedesmal Deinen Source zu posten...

Jo, da wäre ich auch für.

ScrollbarKopf 19. Dez 2007 18:16

Re: Timer programmieren
 
Hat geklabt mit der verkürzten version danke und das mit den source werd ich mir merken :-D


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:16 Uhr.
Seite 2 von 5     12 34     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