Autor Beitrag
casihasi
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Fr 07.04.06 17:12 
also mal erstens sry das ich von meinem letzten thema den titel nicht geändert habe...wie geht das überhaupt?
und zweitens:
kann man diesen Quelltext kürzer schreiben den ich verliere manchmal ein wenig den überblick
ausblenden volle Höhe Delphi-Quelltext
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:
procedure TForm4.Button1Click(Sender: TObject);
begin
if (Form4.edit3.Text= '15') and (Form4.Edit4.text= '15')
or
(Form4.edit3.text='15') and (Form4.edit4.text='17')
or
(Form4.edit3.text='17') and (Form4.Edit4.text='15')
or
(Form4.edit3.text='17') and (Form4.edit4.text='17')
or
(Form4.edit3.text='17') and (Form4.edit5.text='17')
or
(Form4.edit3.text='15') and (Form4.Edit5.text='15')
or
(Form4.edit3.text='15') and (Form4.Edit5.text='17')
or
(Form4.edit3.text='17') and (Form4.edit5.text='15')
or
(Form4.Edit4.text='15') and (Form4.Edit5.text='15')
or
(Form4.edit4.text='15') and (Form4.Edit5.text='17')
or
(Form4.Edit4.text='17') and (Form4.edit5.text='15')
or
(Form4.edit4.text='17') and (Form4.Edit5.text='17')

then
     begin
     name:=Form4.Edit1.Text;
     Form2.edit34.text:=name;
     close;

     end;


if (Form4.edit6.Text='15') and (Form4.Edit7.text='15')
or
(Form4.Edit6.text='15') and (Form4.Edit7.text='15')
or
(Form4.edit6.text='15') and (Form4.Edit7.text='17')
or
(Form4.Edit6.text='17') and (Form4.edit7.text='17')
or
(Form4.edit6.text='17') and (Form4.Edit8.text='17')
or
(Form4.Edit6.text='15') and (Form4.Edit8.text='15')
or
(Form4.Edit6.text='15') and (Form4.Edit8.text='17')
or
(Form4.edit6.text='17') and (Form4.Edit8.text='15')
or
(Form4.Edit7.text='15') and (Form4.edit8.text='15')
or
(Form4.edit7.text='15') and (Form4.Edit8.text='17')
or
(Form4.edit7.text='17') and (Form4.Edit8.text='15')
or
(Form4.edit7.text='17') and (Form4.edit8.text='17')

then
    begin
         name:=Form4.Edit2.Text;
         Form2.edit34.Text:=name;
         close;
         end;
end;

end.


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 07.04.06 17:15 
Ich würde einfach auf >= 15 und um 2 größer als Gegner überprüfen.

_________________
Markus Kinzler.
casihasi Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Fr 07.04.06 17:18 
also >=15 kann ich nicht so gut schreiben da es ja auch 16 17 stehen kann
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Fr 07.04.06 17:21 
... if (StrToInt(Form4.edit6.Text) >= 15) ... ?
trifft doch bei 16 und 17 auch zu

edit: ah jetzt hab ich kapiert, du meinst 16 zu 17 ^^
dann frag doch einfach ab, wer mehr hat

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)


Zuletzt bearbeitet von GSE am Fr 07.04.06 17:22, insgesamt 1-mal bearbeitet
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 07.04.06 17:22 
Also ich antworte jetzt nur noch im neuen Thead.
Zitat:
also >=15 kann ich nicht so gut schreiben da es ja auch 16 17 stehen kann

Deshalb heißt es ja >= (größer/gleich)
In welchem Edit steht was? Punkte Spieler 1/erster Satz, Spieler 2/erster Satz...

_________________
Markus Kinzler.
nullplan001
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win 2000 Professional, Debian Linux 4.0 (Etch,Stable)
Pascal (FreePascal 2.0.2, TurboPascal 7.0), C(++) (G++/GCC 3.4.2 + MinGW), Java (JDK 1.5.0_07), PHP (PHP 5.1.4)
BeitragVerfasst: Fr 07.04.06 17:52 
Äh... Naja, das ist ein wenig viel. Ist auch in der Ausführung nicht sonderlich schnell. Wie wärs mit:
ausblenden volle Höhe Delphi-Quelltext
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:
procedure TForm4.Button1Click(Sender : TObject);
var
  same : set of string;
  e3, e4, e5, e6, e7, e8 : boolean;
begin
  same := ['15','17'];
  e3 := (Form4.edit3.text in same);
  e4 := (Form4.edit4.text in same);
  e5 := (Form4.edit5.text in same);
  e6 := (Form4.edit6.text in same);
  e7 := (Form4.edit7.text in same);
  e8 := (Form4.edit8.text in same);
  if   (e3 and e4 and e5) 
    or (not e3 and e4 and e5)
    or (e3 and not e4 and e5)
    or (e3 and e4 and not e5)
  then begin
    name := Form4.edit1.Text;
    Form2.edit34.text := name;
    close;
  end;
  if   (e3 and e4 and e5)
    or (not e3 and e4 and e5) 
    or (e3 and not e4 and e5) 
    or (e3 and e4 and not e5)
  then begin
    name := Form4.Edit2.Text;
    Form2.edit34.Text := name;
    close;
  end;
end;

Na das sieht doch schon viel freundlicher aus. Wenn du dir unbedingt Arbeit machen willst, kürzt du noch die jetzigen Bedingungen mithilfer der Formeln für Boolesche Algebra, aber das ist nicht notwendig. Du wolltest es doch so, oder? Bedingung ist doch, wenn zwei bzw. drei entweder 15 oder 17 sind, dann tue ... ,oder? Falls das mit den dreien nicht dein Gedanke war, dann kürze beide Bedingungen um die oberste Zeile.
Tschö,
nullplan
//Edit: Das bezog sich jetzt auf den letzten Post von casihasi.

_________________
Ich fahr' nicht selber, weil ich festgestellt habe: ich fahre zu emotional. Bin 180 gefahren wo 30 erlaubt war... -- Jürgen von der Lippe
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 07.04.06 17:58 
Eigentlich ganz einfach:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
   A,B,C: Integer;
const
   D = [15, 17];
Begin
    With Form4 Do
    Begin
        A := StrToInt(Edit3.text);
        B := StrToInt(Edit4.text);
        C := StrToInt(Edit5.text);
    end;

    if (A < 255) And (B < 255) and (C < 255) //Wichtig wegen den folgenden Prüfungen!!!
        ((A in D) and (B in D)) or ((A in D) and (C in D)) or ((B in D) and (C in D)) Then
    Begin
        //Bedingung erfüllt
    end;
end;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 07.04.06 18:05 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function check(s1,s2: boolean;
begin
  Result := ((s1 = s2) and ((strtointdef(s1,0) = 15) or (strtointdef(s1,0) = 17))) or
            (abs((strtointdef(s1,0) - strtointdef(s2,0)) = 2);
end;

if (check(edit3.text, edit4.text) or
    check(edit3.text, edit5.text) or
    check(edit4.text, edit5.text) then
  // irgendwas

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 07.04.06 18:32 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function check(e1,e2,e3:TEdit): boolean;
var
    a,b,c:Integer;
    function i(e:TEdit):integer; begin I := StrToIntDef(e.text,0); end;
    function r(a:Integer):Boolean; Begin Result := ((a and not $1F) = 0) and (a in [15,17]); end;
    function ir(a,b:Integer): Boolean; begin Result := r(a) and r(b); end;
begin
    a:=I(e1);b:=I(e2);c:=I(e3);
    Result := ir(a,b) or ir(a,c) or ir(b,c);
end;

if (check(edit3, edit4, edit5) then
  // irgendwas


Sauber ist der zwar nicht mehr, aber er funzt ;-)

@uall: Bei deinem wäre auch e3=17 und e4=19 gültig ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Fr 07.04.06 18:39 
"Wenn mindestens zwei der Edits eine 15 oder 17 enthalten" <=>
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function FifteenOrSeventeen(A: String): Integer;
begin
 Result := Integer((A='15')or(A='17')); // solche typecasts sollte man eigentlich meiden...
end;
begin
 if FifteenOrSeventeen(Form4.Edit3.Text)+
    FifteenOrSeventeen(Form4.Edit4.Text)+
    FifteenOrSeventeen(Form4.Edit5.Text) >= 2 then
 begin
  // ...
 end;
end;
casihasi Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Sa 08.04.06 11:16 
danke für eure hilfen ich werde versuchen sie zu benutzen nur ich habe noch einen fehler in meinem Programm festgestellt!
wenn das spiel so ausgeht: 1.Satz 17 zu 15 2.Satz 12 zu 15 3.Satz 15 zu 12
dann zeigt er mir an das der jenige gewonnen hat der den zweiten satz 12 zu 15 gewonnen hat dabei stimmt das ja aber nicht es hat ja der andere gewonnen wie kann ich das schreiben damit er mir nicht den falschen gewinner anzeigt?
und kann mir noch jemand sagen wie ich, wenn ich nen quelltext schreibe den in so ein Delphi fenster bekomme :oops: ?
schon mal danke im vorraus
mfg
Carsten