We want to ask questions such as
In which country was the inventor of Java born? 1. Australia 2. Canada 3. Denmark 4. United States
Provide these methods of a class ChoiceQuestion
:
addChoice
to add a choice, and to indicate whether it is the correct oneformat
that formats the question for printingcheckAnswer
that checks whether a student answer is correct.It should be possible to call
ChoiceQuestion q = . . .; q.addChoice("Australia", false); q.addChoice("Canada", true); q.addChoice("Denmark", false); q.addChoice("United States", false);
Store the choices in the provided String[]
array. No lists! Note that you'll have to deal with the fact that the answers come one at a time. Also, you'll want to record the correct answer somehow.