As described in the handout for Part 1, the overall aim of the assignment is to develop a program to administer a quiz test.
In Part 1, you have implemented the classes to represent the quiz questions and answers. You have also written programs to test these classes. In particular, you have written a program to read a number of questions from a text le, administer the questions, obtain the answers, and print out the answer.
Building on the work that you have done for part 1, in this Part 2, you are required to do the tasks described below.
Besides the information given in the tasks below, please refer to Part 1 of the Assignment for any information you need.
Task 1
Write the menu program. Call it QuizTestMenu. The program displays the menu with the options shown in method below:
========
Options:
========
R: Read question details from a text file
A: Administer the quiz test
F: Administer the quiz test with option to quit D: Display the answers on the screen
W: Write the answers to a text file Q: Quit
Please select an option:
Other than the minimum required for the program to compile, no exception handling is required for this task.
Option R. The program asks for the name of the text le (e.g. QuizTest1.txt) and read the questions from this le. The le format is exactly as described in Part 1.
Option A. The way the program administers the quiz questions and obtains the answers is exactly as described in Part 1.
Option F. (F stands for Flexible administration of the quiz test). With this option, after answering a quiz question, the user will be asked if he/she wants to continue or not. If the user chooses to quit, option D is still available to display the result regarding the questions the user has answered before quiting.
Option D. The way the program displays the answer is illustrated by the example below:
QUESTION 1:
A checked exception must be caught or declared.
True or false?
Your answer is: true
It is correct.
QUESTION 2:
What is the keyword used to declare a class to be a subclass of another class?
a) implements
b) extends
c) subclass
d) interface
Your answer is: c
It is incorrect.
The correct answer is: b
...
The display of the result of a quiz test ends with four lines of summary as shown in the example below:
Number of questions in the quiz test: 10
Number of question you have answered: 8
Number of correct answers: 6
Number of incorrect answers: 2
Option W. The program asks for the name of the le to save the result to (e.g. QuizTest1Result.txt). The information to be written and the format are exactly as for displaying the result on the screen.
Task 2
Enhance the menu program so that it is more robust to the extent described below.
You are not required to detect and throw exceptions. However, if some exceptional condition arises for an operation, then this operation is aborted but the program itself does not crash. Thus, all the work up to that point is preserved and further operations (if appropriate) can be taken.
Task 3 (Optional)
Enhance the way your program administer a question so that if the user enters an invalid answer the will keep asking until a valid answer is obtained. A valid answer can be correct or incorrect.
A valid answer for a true/false question, is true or false (ignoring case of the letters), and not something else.
A valid answer for a multiple choice questions with 4 options, for example, must be a or b or c or d.
A valid answer for a word question must not be an empty string. In other words, any non-empty string is a valid answer.
Task 4. (For CSE4IOO students only)
For some quiz questions, the answer is case-sensitive, for example, What is the keyword for a constant? For other questions, it makes no difference whether the answer is in lower case or upper case or a mixture of the two. Suppose we want to take this fact into account. How should we modify the class design?