- {Fait par FireChris}
-
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, Grids, Buttons, StdCtrls, Gauges, Spin, ComCtrls;
-
- type
- TForm1 = class(TForm)
- Gauge1: TGauge;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Button1: TButton;
- StringGrid1: TStringGrid;
- Button3: TButton;
- Label1: TLabel;
- SpinEdit1: TSpinEdit;
- SpinEdit2: TSpinEdit;
- SpinEdit3: TSpinEdit;
- SpinEdit4: TSpinEdit;
- Label7: TLabel;
- Label8: TLabel;
- Timer1: TTimer;
- Button2: TButton;
- LabeledEdit1: TLabeledEdit;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
-
- private
- { Déclarations privées }
- public
-
- Procedure AfichNote;
- procedure question;
- procedure InitialGauge;
- { Déclarations publiques }
-
- end;
-
- var
- Form1: TForm1;
- nb:integer;
-
- implementation
-
- {$R *.dfm}
-
- //--------------------------------------------------------
-
- procedure Tform1.question;
- var a:integer;
- begin
-
- if (SpinEdit1.Value)>(SpinEdit2.Value)
- then begin
- a:=SpinEdit1.Value;
- SpinEdit1.Value:=SpinEdit2.Value;
- SpinEdit2.Value:=a;
- end;
-
- a:=nb;
-
- repeat
- nb:=random(SpinEdit2.Value+1);
- until (nb>=SpinEdit1.Value) and (nb<>a);
-
- a:=random(2);
-
- if a=0
- then
- Label1.Caption:=IntToStr(nb)+' * '+IntToStr(SpinEdit4.Value)
- else
- Label1.Caption:=IntToStr(SpinEdit4.Value)+' * '+IntToStr(nb);
-
- end;
-
- //--------------------------------------------------------
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Randomize;
- end;
-
- //---------------------------------------------------------
-
- procedure TForm1.Button1Click(Sender: TObject);
- var a:integer;
- begin
-
-
-
- if Button1.Caption='Vérifier'
- then begin
-
- InitialGauge;
-
- if nb*SpinEdit4.Value=SpinEdit3.Value
- then begin
- a:=random(5);
- case a of
- 0:ShowMessage('très bien');
- 1:ShowMessage('Magnifique');
- 2:ShowMessage('Tu es le meilleur');
- 3:ShowMessage('Même moi je n''aurais pas réussi');
- 4:ShowMessage('Tu es trop bon');
- end;
- Label4.Caption:=IntToStr(StrToInt(Label4.Caption)+1);
- Label5.Caption:=IntToStr(StrToInt(Label5.Caption)+1);
- question;
- end
- else begin
- a:=random(5);
- case a of
- 0:ShowMessage('tu me déçois. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
- 1:ShowMessage('domage. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
- 2:ShowMessage('Tu aurais pu faire mieux. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
- 3:ShowMessage('La prochaine fois ce sera bon. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
- 4:ShowMessage('ça va mal. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
- end;
- Label5.Caption:=IntToStr(StrToInt(Label5.Caption)+1);
- end
- end
- else begin
- Button1.Caption:='Vérifier';
- Button3.Enabled:=true;
- Label7.Enabled:=false;
- Label8.Enabled:=false;
- Label2.Enabled:=false;
- SpinEdit1.Enabled:=false;
- SpinEdit2.Enabled:=false;
- SpinEdit4.Enabled:=false;
- question;
- end;
-
- if label5.Caption='20'
- then begin
- Button2.Enabled:=true;
- Button1.Enabled:=false;
- Button1.Caption:='Recomencer';
- Button3.Enabled:=false;
- Label1.Caption:='';
- Label7.Enabled:=True;
- Label8.Enabled:=True;
- Label2.Enabled:=True;
- SpinEdit1.Enabled:=True;
- SpinEdit2.Enabled:=True;
- SpinEdit4.Enabled:=True;
- end
- else Timer1.Enabled:=True;
-
- end;
-
- //--------------------------------------------------
-
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
-
- Gauge1.Progress:=Gauge1.Progress+1;
-
- if Gauge1.Progress=70
- then Gauge1.ForeColor:=clYellow;
-
- if Gauge1.Progress=85
- then Gauge1.ForeColor:=clRed;
-
- if Gauge1.Progress=100
- then begin
- InitialGauge;
- Button1.Click;
- end;
-
- end;
-
- //--------------------------------------------------------
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- Timer1.Enabled:=false;
- Gauge1.Progress:=0;
- Gauge1.ForeColor:=clLime;
- Button1.Caption:='Continuer';
- Button3.Enabled:=false;
- Label7.Enabled:=True;
- Label8.Enabled:=True;
- Label2.Enabled:=True;
- SpinEdit1.Enabled:=True;
- SpinEdit2.Enabled:=True;
- SpinEdit4.Enabled:=True;
- Label1.Caption:='';
- end;
-
- //------------------------------------------------------
-
- procedure Tform1.InitialGauge;
- Begin
- Timer1.Enabled:=False;
- Gauge1.Progress:=0;
- Gauge1.ForeColor:=clLime;
- end;
-
- //----------------------------------------------------
-
- Procedure Tform1.AfichNote;
- var a,b:integer;
- non,notebis:string;
- label ecrir;
- begin
- for a:=1 to 5 do
-
- if StringGrid1.Cells[2,a]=''
- then begin
- goto ecrir;
- end
- else begin
- if StrToInt(StringGrid1.Cells[2,a])<StrToInt(label4.Caption)
- then begin
- for b:=1 to 5-a do begin
- non:=StringGrid1.Cells[1,5-b];
- notebis:=StringGrid1.Cells[2,5-b];
- StringGrid1.Cells[1,6-b]:=non;
- StringGrid1.Cells[2,6-b]:=notebis;
- end;
- ecrir:
- StringGrid1.Cells[1,a]:=LabeledEdit1.Text;
- StringGrid1.Cells[2,a]:=label4.Caption;
- Break;
-
-
- end;
-
- end ;
- Label5.Caption:='0';
- Label4.Caption:='0';
- end;
-
-
- //------------------------------------------------------
-
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- AfichNote;
- Button2.Enabled:=false;
- Button1.Enabled:=true;
- end;
-
- end.
{Fait par FireChris}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, Buttons, StdCtrls, Gauges, Spin, ComCtrls;
type
TForm1 = class(TForm)
Gauge1: TGauge;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Button1: TButton;
StringGrid1: TStringGrid;
Button3: TButton;
Label1: TLabel;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
SpinEdit3: TSpinEdit;
SpinEdit4: TSpinEdit;
Label7: TLabel;
Label8: TLabel;
Timer1: TTimer;
Button2: TButton;
LabeledEdit1: TLabeledEdit;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Déclarations privées }
public
Procedure AfichNote;
procedure question;
procedure InitialGauge;
{ Déclarations publiques }
end;
var
Form1: TForm1;
nb:integer;
implementation
{$R *.dfm}
//--------------------------------------------------------
procedure Tform1.question;
var a:integer;
begin
if (SpinEdit1.Value)>(SpinEdit2.Value)
then begin
a:=SpinEdit1.Value;
SpinEdit1.Value:=SpinEdit2.Value;
SpinEdit2.Value:=a;
end;
a:=nb;
repeat
nb:=random(SpinEdit2.Value+1);
until (nb>=SpinEdit1.Value) and (nb<>a);
a:=random(2);
if a=0
then
Label1.Caption:=IntToStr(nb)+' * '+IntToStr(SpinEdit4.Value)
else
Label1.Caption:=IntToStr(SpinEdit4.Value)+' * '+IntToStr(nb);
end;
//--------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;
//---------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var a:integer;
begin
if Button1.Caption='Vérifier'
then begin
InitialGauge;
if nb*SpinEdit4.Value=SpinEdit3.Value
then begin
a:=random(5);
case a of
0:ShowMessage('très bien');
1:ShowMessage('Magnifique');
2:ShowMessage('Tu es le meilleur');
3:ShowMessage('Même moi je n''aurais pas réussi');
4:ShowMessage('Tu es trop bon');
end;
Label4.Caption:=IntToStr(StrToInt(Label4.Caption)+1);
Label5.Caption:=IntToStr(StrToInt(Label5.Caption)+1);
question;
end
else begin
a:=random(5);
case a of
0:ShowMessage('tu me déçois. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
1:ShowMessage('domage. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
2:ShowMessage('Tu aurais pu faire mieux. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
3:ShowMessage('La prochaine fois ce sera bon. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
4:ShowMessage('ça va mal. '+IntToStr(nb)+' * '+InttoStr(SpinEdit4.Value)+' = '+IntToStr(nb*SpinEdit4.Value));
end;
Label5.Caption:=IntToStr(StrToInt(Label5.Caption)+1);
end
end
else begin
Button1.Caption:='Vérifier';
Button3.Enabled:=true;
Label7.Enabled:=false;
Label8.Enabled:=false;
Label2.Enabled:=false;
SpinEdit1.Enabled:=false;
SpinEdit2.Enabled:=false;
SpinEdit4.Enabled:=false;
question;
end;
if label5.Caption='20'
then begin
Button2.Enabled:=true;
Button1.Enabled:=false;
Button1.Caption:='Recomencer';
Button3.Enabled:=false;
Label1.Caption:='';
Label7.Enabled:=True;
Label8.Enabled:=True;
Label2.Enabled:=True;
SpinEdit1.Enabled:=True;
SpinEdit2.Enabled:=True;
SpinEdit4.Enabled:=True;
end
else Timer1.Enabled:=True;
end;
//--------------------------------------------------
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Gauge1.Progress:=Gauge1.Progress+1;
if Gauge1.Progress=70
then Gauge1.ForeColor:=clYellow;
if Gauge1.Progress=85
then Gauge1.ForeColor:=clRed;
if Gauge1.Progress=100
then begin
InitialGauge;
Button1.Click;
end;
end;
//--------------------------------------------------------
procedure TForm1.Button3Click(Sender: TObject);
begin
Timer1.Enabled:=false;
Gauge1.Progress:=0;
Gauge1.ForeColor:=clLime;
Button1.Caption:='Continuer';
Button3.Enabled:=false;
Label7.Enabled:=True;
Label8.Enabled:=True;
Label2.Enabled:=True;
SpinEdit1.Enabled:=True;
SpinEdit2.Enabled:=True;
SpinEdit4.Enabled:=True;
Label1.Caption:='';
end;
//------------------------------------------------------
procedure Tform1.InitialGauge;
Begin
Timer1.Enabled:=False;
Gauge1.Progress:=0;
Gauge1.ForeColor:=clLime;
end;
//----------------------------------------------------
Procedure Tform1.AfichNote;
var a,b:integer;
non,notebis:string;
label ecrir;
begin
for a:=1 to 5 do
if StringGrid1.Cells[2,a]=''
then begin
goto ecrir;
end
else begin
if StrToInt(StringGrid1.Cells[2,a])<StrToInt(label4.Caption)
then begin
for b:=1 to 5-a do begin
non:=StringGrid1.Cells[1,5-b];
notebis:=StringGrid1.Cells[2,5-b];
StringGrid1.Cells[1,6-b]:=non;
StringGrid1.Cells[2,6-b]:=notebis;
end;
ecrir:
StringGrid1.Cells[1,a]:=LabeledEdit1.Text;
StringGrid1.Cells[2,a]:=label4.Caption;
Break;
end;
end ;
Label5.Caption:='0';
Label4.Caption:='0';
end;
//------------------------------------------------------
procedure TForm1.Button2Click(Sender: TObject);
begin
AfichNote;
Button2.Enabled:=false;
Button1.Enabled:=true;
end;
end.