Autor Beitrag
Kia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Di 19.09.06 12:25 
Hallo

Ich Programmieren grad an einem Wer wird Millionär Spiel. Zwar hab ich schon eine 1.0 Version rausgebracht aber die ist noch eher nich so toll :>

www.delphi-forum.de/...ionaer+10_64637.html

Ich möchte jetzt gern Random fragen haben. In meiner alten Version hatte ich nur 15 Fragen für jeden Geldbetrag halt eine Frage.

Nun möchte ich gern zu jedem Geldbetrag 10-20 Fragen haben, aber wie mach ich das jetzt, das Delphi immer halt zufählig die Fragen rauspickt zum jeweiligen Geldbetrag.

Hierzu kommt noch der Joker. Der Joker soll erkennen welche Antwort richtig oder falsch ist und halt Random 2 Falsche durch ein "-" ersetzten.



Ich hoffe ihr versteht mein problem = /


Zuletzt bearbeitet von Kia am Di 19.09.06 12:45, insgesamt 1-mal bearbeitet
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Di 19.09.06 12:35 
Hallo,

ich weiss nicht, wie du deine Fragen gespeichert hast, deshalb gehe ich jetzt von einer StringList (vgl. Array) aus. Dann geht das ganz einfach:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  //Beim STart (OnCreate)
  Randomize;
  //SL = TStringListe
  SL.Items[Random(SL.Count - 1)];
Gruß Hape!

P.S.: Ist es jetzt üblich deutsch und englisch zu vermischen?

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Di 19.09.06 12:39 
Ich hoffe auch, ich versteh dich richtig

Ich würde ein Array of Array [0..5] of string machen. Kennst du Arrays schon?
das sind sowas wie tabellen, meine ist zweidimensional:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Frage | Antw1 | Antw2 | Antw3 | Antw4 | RichtigeAntwort
fr1     a11     a21     a31     a41     antw1
fr2     a12     a22     a32     a42     antw2
fr3     a13     a23     a33     a43     antw3
fr4     a14     a24     a34     a44     antw4


In der Tabelle steht also alles, was du brauchst. Mit Random kannst du dir eine frage rauspicken.
Kia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Di 19.09.06 12:43 
Ich benutze für die Frage ein label
und für die Antworten Buttons und hab halt 15 Button untereinader geschoben


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Label1.Caption:='Können alle Insekten fliegen ?';
BTantwortA15.Caption:='Ja';
BTantwortB15.Caption:='nein';
BTantwortC15.Caption:='nur die Männchen';
BTantwortD15.Caption:='nur die Weibchen';

Label1.Caption:='Wer würde bei der Fussball WM 2002 Weltmeister ?';
BTantwortA14.Caption:='Brasilien';
BTantwortB14.Caption:='Frankreich';
BTantwortC14.Caption:='Deutschland';
BTantwortD14.Caption:='Italien';
form1.Color:=clBtnFace;
BTgeld0.Visible:=false;
BTantwortA15.Visible:=false;
BTantwortB15.Visible:=false;
BTantwortC15.Visible:=false;
BTantwortD15.Visible:=false;
end;

und so weiter

So ungefähr halt, glaub sehr umständlich aber hab Delphi erst seid einer Woche und kenn mich halt noch nicht so gut aus.
und zufählig klingt für mich zu dumm = / genau wie website und etc spricht man ja auch nur das englische aus :p

@Jakob Schöttl ne kenn ich noch nicht :(

Moderiert von user profile iconjasocul: Delphi-Tags hinzugefügt
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Di 19.09.06 13:02 
user profile iconKia hat folgendes geschrieben:
@Jakob Schöttl ne kenn ich noch nicht :(

Dann lern's!

Glaub mir, das ist viel besser. Dann sparst du dir auch die 15 Buttons (ersetzt sie durch 4 für die 4 Antworten) weil du dann einfach nur die Beschriftung änderst. Du kannst dann immer mehr Fragen anhängen, ohne etwas umprogrammieren zu müssen ...

Ich versuch dich mal bisschen einzuführen ins Array:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
//Die Deklaration:
var Liste: Array [0..5] of string; //eine Liste von Strings mit 6 Einträgen
begin
  for n := 0 to 5 do Memo1.Lines.Add(Liste[n]); //hier schreibst du alle Einträge in ein Memo
//indem du hinter die variable "Liste" "[Index]" schreibst, rufst du das Element mit dem Index "Index" auf. Index muss eine Ganze zahl sein, die eben den Index der "Zeile" angibt.
end;


Schau dir auch die Delphi hilfe an, und vllt kennt ja jemand ein gutes tutorial
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 19.09.06 13:18 

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Di 19.09.06 13:31 
noch besser wäre statt einem 2-dimensionalem array ein type:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type TQuestion=record
 Question: string;
 WrongAnswer: array [1..3] of String;
 RightAnswer: String;
 Price: String; //oder für jeden Geldbetrag eine eigene Variable,z.B. Q1000000: array [1..100] of TQuestion 
end;

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Jakob Schöttl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 929
Erhaltene Danke: 1


Delphi 7 Professional
BeitragVerfasst: Di 19.09.06 13:44 
Stimmt, daran hab ich gar nicht gedacht. Klar, also Kia schau dir mal Arrays und Records an!
Kia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Di 19.09.06 20:26 
danke an alle ich versuchs jetzt ma mit bisschen probieren kriege ich es schon ihrgend wie hin :p
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 19.09.06 20:51 
Mann muss trotzdem nochmal probieren, ob was anderes raus kommt.
Schau doch mal nach dem was Dir vorgeschlagen wird !
www.delphi-forum.de/...64637&highlight=

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Kia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 20.09.06 07:02 
die sachen hab ich schon verbessert, aber danke :)
jsfrigo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

win xp, Win7
D2010
BeitragVerfasst: Mi 20.09.06 07:14 
Also das Speichern der Fragen in einem Array halte ich für nicht so gut.
Speichere die Sachen doch in einer Datenbank.
Da ist es dann doch viel leichter später noch Fragen hinzuzufügen.
Es sollte eine Tablelle genügen.
Gruss
Jörg