Autor Beitrag
xilos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 05.03.07 17:28 
hi...

wir habe in der schule einen iq-test gemacht...jedoch habe ich ein paar sachen nicht ganz verstanden und wollte hier noch mal nachfragen
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:
69:
70:
71:
72:
73:
unit Quiz;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edit2: TEdit;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var d:Integer;  message:string;

begin

If edit1.Text = 'a' then
  begin
  d:=1;
  messagedlg('Sie haben Frage 1 richtig beantwortet.', mtInformation, [mbOK], 0);
  end
else
  begin
  messagedlg('Sie haben Frage 1 falsch beantwortet.', mtInformation, [mbOK], 0);
  d:=0;
  end;

If edit2.Text = '15' then
  begin
  messagedlg('Sie haben Frage 2 richtig beantwortet.', mtInformation, [mbOK], 0);
  d:=d+1;
  end
else
  begin
  messagedlg('Sie haben Frage 2 falsch beantwortet.', mtInformation, [mbOK], 0);
  d:=d;
  end;

case d of
0:message:= 'Sie sollten noch etwas üben.';
1:message:= 'Sie sind durchschnittlich begabt.';
2:message:= 'Sie sind sehr Intelligent.';
end;

messagedlg(message, mtInformation, [mbOK], 0);
end;


end.


das hier ist der komplette quellcode!!!
bei den ganzen if und else funktionen wird immer d:=?? gesetzt...für was steht denn dieses d?? hat das irgendwas mit dem case of zu tun?? wenn ja wo ist im case of d:=d+1 oder d:=d??


thx jetzt schon mal
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: Mo 05.03.07 17:35 
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:
69:
70:
unit Quiz;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edit2: TEdit;
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var right_answers: integer; //was sagt d denn aus?
   msg: string; //message ist reserviert -> nimm lieber msg ;)

begin
  right_answers := 0;
  if (edit1.Text = 'a') then
  begin
    inc(right_answers);
    messagedlg('Sie haben Frage 1 richtig beantwortet.', mtInformation, [mbOK], 0);
  end
  else begin
    messagedlg('Sie haben Frage 1 falsch beantwortet.', mtInformation, [mbOK], 0);
  end;
   
  if (edit2.Text = '15') then
  begin
    inc(right_answers);  
    messagedlg('Sie haben Frage 2 richtig beantwortet.', mtInformation, [mbOK], 0);
  end 
  else begin
     messagedlg('Sie haben Frage 2 falsch beantwortet.', mtInformation, [mbOK], 0);
  end;

case right_answers of
0: msg:= 'Sie sollten noch etwas üben.';
1: msg:= 'Sie sind durchschnittlich begabt.';
2: msg:= 'Sie sind sehr Intelligent.';
end;

messagedlg(msg, mtInformation, [mbOK], 0);
end;


end.

d zählt die Anzahl der richtigen Antworten. Habe mal einiges verändert. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
xilos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 05.03.07 17:38 
okay das ist leichter zu verstehen ^^....aber was soll dieses inc(right_anwer); heißen??
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Mo 05.03.07 17:41 
Moin,

Inc heißt increment - erhöhen. Statdessen hätte man auch
ausblenden Delphi-Quelltext
1:
 right_answers := right_answers + 1;					

schreiben können.

Gruß

Saubäär
xilos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mo 05.03.07 18:31 
und was soll er in diesem fall erhöhen?? das verstehe ich noch nicht ganz
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: Mo 05.03.07 18:37 
Wenn right_answers z.B. 0 ist, dann wird es nach inc(right_answers) eben 1. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
xilos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 59



BeitragVerfasst: Mi 07.03.07 14:31 
noch mal eine kleine frage...
...was bedeutet denn : string bei den variablen??
irgendwas mit Zeilen?? :S
Witchblade
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Mi 07.03.07 14:44 
user profile iconxilos hat folgendes geschrieben:
noch mal eine kleine frage...
...was bedeutet denn : string bei den variablen??
irgendwas mit Zeilen?? :S


string ist ein datentyp dem du alphanumerische daten zuweisen kannst.
integer sind ganzzahlen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
TForm1.Button1Click(Sender: TObject);  
var 
   zahl        : Integer;  
   text        : String;  
begin  
   text := 'Das ist ein Text 12345'; 
   zahl := 1;
end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt