Code:
//unit assignment4_MDJ_u;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TfrmIntermediate = class(TForm)
imgBackRound: TImage;
imgWrong: TImage;
imgCorrect: TImage;
lblTime: TLabel;
gbMultiply: TGroupBox;
lbltotalcomple: TLabel;
BitBtnMultiply: TBitBtn;
gbAdd: TGroupBox;
lblTotalcomp: TLabel;
BitBtnAdd: TBitBtn;
gbSubtract: TGroupBox;
lbltotalcompl: TLabel;
BitBtnSubtract: TBitBtn;
gbDivide: TGroupBox;
lbltotalcomplet: TLabel;
BitBtnDivide: TBitBtn;
gbChoice2: TGroupBox;
btnAdd: TButton;
btnMutiply: TButton;
btnSubtraction: TButton;
btnDivide: TButton;
BitBtnCancel: TBitBtn;
BitBtnBack: TBitBtn;
pnlClosePage: TPanel;
lblExit: TLabel;
ImgSad: TImage;
BitBtnNo: TBitBtn;
BitBtnYes: TBitBtn;
bmbScores: TBitBtn;
gbPlayer: TGroupBox;
lblPlayer: TLabel;
bmbplayer1: TBitBtn;
bmbPlayer2: TBitBtn;
bmbplayer3: TBitBtn;
bmbplayer4: TBitBtn;
bmbplayer5: TBitBtn;
bmbplayer6: TBitBtn;
PnlTotalans: TPanel;
lblTotalwrong: TLabel;
lblTotalCorr: TLabel;
lblTotal: TLabel;
pnl1: TPanel;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
pnl3: TPanel;
lbl7: TLabel;
lbl8: TLabel;
lbl9: TLabel;
pnl5: TPanel;
lbl13: TLabel;
lbl14: TLabel;
lbl15: TLabel;
pnl2: TPanel;
lbl4: TLabel;
lbl5: TLabel;
lbl6: TLabel;
pnl4: TPanel;
lbl10: TLabel;
lbl11: TLabel;
lbl12: TLabel;
tmSystem: TTimer;
procedure bmbScoresClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure BitBtnAddClick(Sender: TObject);
procedure BitBtnAddMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure BitBtnMultiplyClick(Sender: TObject);
procedure BitBtnMultiplyMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure BitBtnSubtractClick(Sender: TObject);
procedure BitBtnSubtractMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
procedure BitBtnDivideClick(Sender: TObject);
procedure BitBtnDivideMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure bmbPlayer2Click(Sender: TObject);
procedure bmbplayer3Click(Sender: TObject);
procedure bmbplayer4Click(Sender: TObject);
procedure bmbplayer5Click(Sender: TObject);
procedure bmbplayer6Click(Sender: TObject);
procedure BitBtnYesClick(Sender: TObject);
procedure BitBtnNoClick(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btnMutiplyClick(Sender: TObject);
procedure btnSubtractionClick(Sender: TObject);
procedure btnDivideClick(Sender: TObject);
procedure BitBtnCancelClick(Sender: TObject);
procedure bmbplayer1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmIntermediate: TfrmIntermediate;
inputstr : string;
iRight, iWrong, iRightAll, iWrongAll, iadd1, iadd2,iresult, iresult2: Integer;
player : integer;
implementation
uses assignment2_MDJ_u, assignment9_MDJ_u, assignment3_MDJ_u,
assignment7_MDJ_u, assignment10_MDJ_u;
{$R *.dfm}
procedure sub;
begin
repeat
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
until iadd1 > iadd2;
if iadd1 > iadd2 then
iResult := iAdd1 - iAdd2 else
iAdd2 := Random(20) + 1;
end;
procedure TfrmIntermediate.bmbScoresClick(Sender: TObject);
begin
frmIntermediate.Visible := False;
frmIntermediateScore.Visible := True;
if strtoint(lbltotalcorr.Caption) > (strtoint(lbl1.Caption) and strtoint(lbl4.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName1.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lblTotalCorr.Caption;
end
else begin
if strtoint(lbl1.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl4.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName2.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl1.Caption;
end
else begin
if strtoint(lbl4.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName3.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl4.Caption;
end
else begin
if strtoint(lbl7.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName4.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl7.Caption;
end
else begin
if strtoint(lbl10.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl7.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName5.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl10.Caption;
end
else begin
if strtoint(lbl13.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl7.Caption) and strtoint(lbl10.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName6.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl13.Caption;
end
else begin
frmscoresenior.pnlHigh.Visible := False;
end;
end;
end;
end;
end;
end;
end;
procedure TfrmIntermediate.FormActivate(Sender: TObject);
begin
iRightAll := 0;
iRightAll := 0;
iRight := 0;
iWrong := 0;
frmPrimary.Brush.Color := clBtnFace;
lbltotalcorr.Caption := '0';
lblTotalwrong.Caption := '0';
lblTotal.Caption := '0';
lbl1.Caption := '0';
lbl2.Caption := '0';
lbl3.Caption := '0';
lbl4.Caption := '0';
lbl5.Caption := '0';
lbl6.Caption := '0';
lbl7.Caption := '0';
lbl8.Caption := '0';
lbl9.Caption := '0';
lbl10.Caption := '0';
lbl11.Caption := '0';
lbl12.Caption := '0';
lbl13.Caption := '0';
lbl14.Caption := '0';
lbl15.Caption := '0';
end;
procedure TfrmIntermediate.BitBtnAddClick(Sender: TObject);
var
A, icounter : integer;
begin
icounter := 0;
if player = 1 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lblTotalCorr.Caption := IntToStr(iRightAll) else
lblTotalwrong.Caption := IntToStr(iWrongAll);
lblTotal.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 2 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl1.Caption := IntToStr(iRightAll) else
lbl2.Caption := IntToStr(iWrongAll);
lbl3.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 3 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl4.Caption := IntToStr(iRightAll) else
lbl5.Caption := IntToStr(iWrongAll);
lbl6.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 4 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl7.Caption := IntToStr(iRightAll) else
lbl8.Caption := IntToStr(iWrongAll);
lbl9.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 5 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl10.Caption := IntToStr(iRightAll) else
lbl11.Caption := IntToStr(iWrongAll);
lbl12.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 6 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) + '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl13.Caption := IntToStr(iRightAll) else
lbl14.Caption := IntToStr(iWrongAll);
lbl15.Caption := IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
end;
procedure TfrmIntermediate.BitBtnAddMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;
procedure TfrmIntermediate.BitBtnMultiplyClick(Sender: TObject);
var
A, iCounter : integer;
begin
icounter := 0;
if player = 1 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 2 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 3 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 4 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 5 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 6 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) + 'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
iRight := (iRight + 1) else
iRight := (iRight + 1);
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
end;
procedure TfrmIntermediate.BitBtnMultiplyMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;
procedure TfrmIntermediate.BitBtnSubtractClick(Sender: TObject);
var
icounter : integer;
begin
icounter := 0;
if player = 1 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 2 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 3 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 4 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 5 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 6 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) + '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
iCounter := icounter + 1;
lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
end;
procedure TfrmIntermediate.BitBtnSubtractMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;
procedure TfrmIntermediate.BitBtnDivideClick(Sender: TObject);
var
counter : integer;
begin
counter := 0;
if player = 1 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 2 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 3 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 4 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 5 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 6 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult := iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) + '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
If StrToInt(Inputstr) = iResult then
inc(iRight,1) else
inc(iWrong,1);
If StrToInt(Inputstr) = iResult
then begin
imgCorrect.Visible := True;
imgWrong.Visible := False;
end;
If StrToInt(Inputstr) <> iResult
then begin
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
If StrToInt(Inputstr) = iResult then
showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
If StrToInt(Inputstr) = iResult then
inc(iRightAll,1) else
inc(iWrongAll,1);
if StrToInt(Inputstr) = iResult then
lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
counter := counter + 1;
lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
end;
procedure TfrmIntermediate.BitBtnDivideMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;
procedure TfrmIntermediate.bmbPlayer2Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 2;
end;
procedure TfrmIntermediate.bmbplayer3Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 3;
end;
procedure TfrmIntermediate.bmbplayer4Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 4;
end;
procedure TfrmIntermediate.bmbplayer5Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 5;
end;
procedure TfrmIntermediate.bmbplayer6Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 6;
end;
procedure TfrmIntermediate.BitBtnYesClick(Sender: TObject);
begin
gbAdd.Visible := false;
gbSubtract.Visible := False;
gbMultiply.Visible := False;
frmPhase.Show;
pnlClosePage.Visible := False;
frmPrimary.Visible := False;
imgCorrect.Visible := False;
imgWrong.Visible := True;
end;
procedure TfrmIntermediate.BitBtnNoClick(Sender: TObject);
begin
pnlClosePage.Visible := False;
bitbtnBack.Visible := True;
end;
procedure TfrmIntermediate.btnAddClick(Sender: TObject);
begin
gbAdd.Visible := True;
gbChoice2.Visible := False;
bitbtnAdd.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;
procedure TfrmIntermediate.btnMutiplyClick(Sender: TObject);
begin
gbMultiply.Visible := True;
gbChoice2.Visible := False;
bitBtnMultiply.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;
procedure TfrmIntermediate.btnSubtractionClick(Sender: TObject);
begin
gbSubTract.Visible := True;
gbChoice2.Visible := False;
bitbtnSubtract.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;
procedure TfrmIntermediate.btnDivideClick(Sender: TObject);
begin
gbDivide.Visible := True;
gbChoice2.Visible := False;
bitbtnDivide.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;
procedure TfrmIntermediate.BitBtnCancelClick(Sender: TObject);
begin
frmPhase.Visible := True;
frmPrimary.Visible := False;
end;
procedure TfrmIntermediate.bmbplayer1Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 1;
end;
end.//
Ihope this helps.
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum