Autor Beitrag
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 26.04.06 09:45 
hi
habe das Forum ein bissle durchforstet aber nichts passendes für mein Programm gefunden.
wie in der überschrifft schon genannt geht es hierbei um ein Lottospiel.
Unser Lehrer hat gemeint wenn mann auf einen Button klickt soll das wie beim Lotto ablaufen für jede zahl gibt es ein edit feld.
nun habe ich etwas gefunden, dort schreibt er mir aber alles in ein editfeld und nicht in 6.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TLottozahlen.Button1Click(Sender: TObject);
 var Zahlen: Array[1..49of Boolean;
     i, z: Integer;
begin
  for i:= 1 to 49 do Zahlen[i]:=false;
  for i:=1 to 6 do begin
   repeat
    z:=random(49)+1
   until Zahlen[z] = false;
   Zahlen[z]:=true;
  end;

  Edit1.Text:='';
  for i:=1 to 49 do
  if Zahlen[i] then Edit1.Text:=Edit1.Text+' '+Inttostr(i)+' ';
end;



hoffe es kann mir einer Helfen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 26.04.06 10:17 
Moin!

user profile iconchriss1988 hat folgendes geschrieben:
hoffe es kann mir einer Helfen

Klar, wenn du gesagt hättest, wobei... ;) Oder sollen wir dir einfach gleich das Programm schreiben und du hast dich nur nicht getraut zu fragen? :D

cu
Narses

PS: Hausaufgaben sind dazu da, um sich selbst damit zu beschäftigen. ;) Sag doch mal deinem Lehrer, dass du damit nicht klar kommst, woher soll er denn wissen, ob er den Stoff gut vermittelt hat.

_________________
There are 10 types of people - those who understand binary and those who don´t.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 26.04.06 10:35 
Du musst einfach nur der Reihe nach die Edits prüfen, ob schon was drin steht. Falls nicht, kannst du was reinschreiben, falls doch, dann eben nicht.
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 26.04.06 11:27 
@Narses
nein mir soll keiner ein programm schreiben wollte nur wissen was ich machen muss damit er mir die erste zahl in edit1 schreibt die 2 zahl in edit2 usw.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 26.04.06 11:43 
Moin!

Hmm, ich mach dir mal einen Vorschlag:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Edit1.Text := IntToStr(Random(49)+1);
Edit2.Text := IntToStr(Random(49)+1);
Edit3.Text := IntToStr(Random(49)+1);
Edit4.Text := IntToStr(Random(49)+1);
Edit5.Text := IntToStr(Random(49)+1);
Edit6.Text := IntToStr(Random(49)+1);

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Simon Joker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236
Erhaltene Danke: 1



BeitragVerfasst: Mi 26.04.06 12:54 
@Narses

Das wird 'ne sehr seltsame Ziehung!
Und die Lottozahlen: 7 .. 12 .. 12 .. 25 .. 34 .. 34

Duplicate beim Lotto würden Aufstände hervorrufen. ;-)

Vorschlag:
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:
procedure TLottozahlen.Button1Click(Sender: TObject);
 var PoolList : TStringList;
     i,PoolIndex: Integer;
begin
  PoolList := TStringList.Create;
  try
    //ZahlenPool füllen
    for i:=1 to 49 do
      PoolList.Add(IntToStr(i)); 
    //Zieheung
    for i:=1 to 6 do 
    begin
      PoolIndex := random(PoolList.Count); //Zahl ziehen
      //FindComponent setzt 6 durchnumerierte Edits voraus -> siehe Forum und OH
      TEdit(FindComponent('Edit'+IntToStr(i))).Text := PoolList.Strings[PoolIndex]; 
      //Das ist ein kleiner Trick um sowas zuvermeiden 
      //(Code ab hier nicht nötig!)
      case i of
        1 : Edit1.Text := PoolList.Strings[PoolIndex]; 
        2 : Edit2.Text := PoolList.Strings[PoolIndex];
        3 : Edit3.Text := PoolList.Strings[PoolIndex];
        4 : Edit4.Text := PoolList.Strings[PoolIndex];
        5 : Edit5.Text := PoolList.Strings[PoolIndex];
        6 : Edit6.Text := PoolList.Strings[PoolIndex];
      end;
      //(Ende unötiger Code!)
      PoolList.Delete(PoolIndex); //gezogene Zahl aus Pool entfernen
    end;
  finally
    PoolList.Free;
  end;
end;


MfG Simon
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 26.04.06 13:00 
...war klar, dass einer fertigen Code abliefert... :roll:

_________________
There are 10 types of people - those who understand binary and those who don´t.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 26.04.06 15:09 
Hast du was anderes erwartet? :wink:
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 26.04.06 15:20 
danke für die hilfe
aber ich hatte es schon anders halt viel viel viel viel viel umständlicher.

also nochmals danke