import GUI
View.Set ("graphics")
%%%%%%%%%%%%%%%%%%
% %
% QUESTION 1 %
% %
%%%%%%%%%%%%%%%%%%
% Declare the variable(s) for each radio button to be used.
var ans1: int
var ans2: int
var ans3: int
var ans4: int
% Declare the procedure(s) to be used with the radio buttons. I customized my
% radio buttons so that when one of them is selected, all the other radio
% buttons are disable. This ensures the user only chooses one (1) answer.
procedure status1 (filled : boolean)
if filled then
GUI.Disable (ans2)
GUI.Disable (ans3)
GUI.Disable (ans4)
else
GUI.Enable (ans2)
GUI.Enable (ans3)
GUI.Enable (ans4)
end if
end status1
procedure status2 (filled : boolean)
if filled then
GUI.Disable (ans1)
GUI.Disable (ans3)
GUI.Disable (ans4)
else
GUI.Enable (ans1)
GUI.Enable (ans3)
GUI.Enable (ans4)
end if
end status2
procedure status3 (filled : boolean)
if filled then
GUI.Disable (ans1)
GUI.Disable (ans2)
GUI.Disable (ans4)
else
GUI.Enable (ans1)
GUI.Enable (ans2)
GUI.Enable (ans4)
end if
end status3
procedure status4 (filled : boolean)
if filled then
GUI.Disable (ans1)
GUI.Disable (ans2)
GUI.Disable (ans3)
else
GUI.Enable (ans1)
GUI.Enable (ans2)
GUI.Enable (ans3)
end if
end status4
% Finally, create the check boxes that will be used to select the answer.
ans1 := GUI.CreateCheckBox (10, 10, "Check Box 1",
status1)
ans2 := GUI.CreateCheckBoxFull (200, 10, "Check Box 2",
status2, GUI.RIGHT, '2')
ans3 := GUI.CreateCheckBoxFull (200, 50, "Check Box 3",
status3, GUI.RIGHT, '2')
ans4 := GUI.CreateCheckBoxFull (200, maxy - 20, "Check Box 4",
status4, GUI.RIGHT, '2')
% Make a submit button to clear the screen and introduce the next question.
var quitBtn : int := GUI.CreateButton (230, 10, 0, "Next Question", GUI.Quit)
% These statements will allow us to properly use the submit button.
loop
exit when GUI.ProcessEvent
end loop
% Now, we have to know the status of the checkboxex to know whether the answer
% is correct or not.
var ans1status : boolean := GUI.GetCheckBox (ans1)
var ans2status : boolean := GUI.GetCheckBox (ans2)
var ans3status : boolean := GUI.GetCheckBox (ans3)
var ans4status : boolean := GUI.GetCheckBox (ans4)
% We are now making sure that the correct answer is chosen.
if ans3status= true then
put "Congratulations. You are correct."
else
cls
delay (100)
put "Wrong answer"
end if
%%%%%%%%%%%%%%%%%%
% %
% QUESTION 2 %
% %
%%%%%%%%%%%%%%%%%%
% Declare the variable(s) for each radio button to be used.
var ans11: int
var ans12: int
var ans13: int
var ans14: int
% Declare the procedure(s) to be used with the radio buttons. I customized my
% radio buttons so that when one of them is selected, all the other radio
% buttons are disable. This ensures the user only chooses one (1) answer.
procedure status11 (filled : boolean)
if filled then
GUI.Disable (ans12)
GUI.Disable (ans13)
GUI.Disable (ans14)
else
GUI.Enable (ans12)
GUI.Enable (ans13)
GUI.Enable (ans14)
end if
end status11
procedure status12 (filled : boolean)
if filled then
GUI.Disable (ans11)
GUI.Disable (ans13)
GUI.Disable (ans14)
else
GUI.Enable (ans11)
GUI.Enable (ans13)
GUI.Enable (ans14)
end if
end status12
procedure status13 (filled : boolean)
if filled then
GUI.Disable (ans11)
GUI.Disable (ans12)
GUI.Disable (ans14)
else
GUI.Enable (ans11)
GUI.Enable (ans12)
GUI.Enable (ans14)
end if
end status13
procedure status14 (filled : boolean)
if filled then
GUI.Disable (ans11)
GUI.Disable (ans12)
GUI.Disable (ans13)
else
GUI.Enable (ans11)
GUI.Enable (ans12)
GUI.Enable (ans13)
end if
end status14
% Finally, create the check boxes that will be used to select the answer.
ans11 := GUI.CreateCheckBox (10, 10, "Check Box 1",
status11)
ans12 := GUI.CreateCheckBoxFull (200, 10, "Check Box 2",
status12, GUI.RIGHT, '2')
ans13 := GUI.CreateCheckBoxFull (200, 50, "Check Box 3",
status13, GUI.RIGHT, '2')
ans14 := GUI.CreateCheckBoxFull (200, maxy - 20, "Check Box 4",
status14, GUI.RIGHT, '2')
% Make a submit button to clear the screen and introduce the next question.
var quitBtn2 : int := GUI.CreateButton (230, 10, 0, "Next Question", GUI.Quit)
% These statements will allow us to properly use the submit button.
loop
exit when GUI.ProcessEvent
end loop
% Now, we have to know the status of the checkboxex to know whether the answer
% is correct or not.
var ans11status : boolean := GUI.GetCheckBox (ans11)
var ans12status : boolean := GUI.GetCheckBox (ans12)
var ans13status : boolean := GUI.GetCheckBox (ans13)
var ans14status : boolean := GUI.GetCheckBox (ans14)
% We are now making sure that the correct answer is chosen.
if ans13status= true then
put "Congratulations. You are correct."
else
cls
delay (100)
put "Wrong answer"
end if
|