In Chapter 6, we
did something similar with
GetStarted
,
Ini
tial
ize
,
RightAnswer
, and
WrongAnswer
, us ing stars for feedback and not keeping
score. The sig nificant ad ditions to this script are the vari ables:
numCorrect
and
numIncorrect
.
numCorrect
con tains the number of questions answered cor-
rectly.
numIncorrect
con tains the number of questions answered in correctly.
Each time
a cor rect an swer is chosen, the procedure
RightAnswer
is called in
which
numCorrect
is in creased by one (
numCorrect = numCorrect + 1
).
Each
time a wrong an swer is chosen, the pro cedure
WrongAnswer
is called in
which
numIncorrect
is in
creased by one (
numIncorrect =
numIncorrect + 1
). When you want to
find out how you are do ing, call the
pro ce dure
Feed
back
to
dis play a
MsgBox
with how many questions were right
(
numCorrect
) out of how many were an
swered (
numCorrect +
numIncorrect
).
In addition, before the test starts, call the pro
cedure
GetStarted
to ini tialize the vari ables (set
numCorrect
and
numIncorrect
to 0), ask for the student’s name, and move to the first question. Other than the
variables, all the parts of this script are things you have seen before.
You might want to report the score in other forms. Now that we know how
many questions were an swered correctly and how many
were an swered in cor-
rectly, you can ad just the
Do'stlaringiz bilan baham: