In this assignment, which consists of two parts, you will develop a program to administer a quiz test. The program (which is to be completed in part 2) presents the user with a menu with the following options:
Quiz Questions
There are three types of quiz questions:
True or false questions
The interaction for a true or false question is as shown in the example below:
A checked exception must be caught or declared.
True or false?
Type true or false in lower case: true
That is, the program displays
Multiple choice questions
The interaction for a multiple choice question is as shown in the example below:
What is the keyword used to declare a class to be a subclass of another class?
a) implements
b) extends
c) subclass
d) interface
Type a letter between a and d inclusive: b
That is, the program displays
Word questions
For this type of question, the users answer consists of one or more words. Two examples are shown below. In the rst example, a question is asked. In the second example, a blank in a statement is to be lled in.
What is the key word for constant?
Type in your answer (use capital letters only when necessary): final
ArithmeticException is a/an _____ exception. Fill in the blank.
Type in your answer (use capital letters only when necessary): checked
That is, the program displays
Class Design
A design of the classes are shown below. The diagram includes all the attributes, but it includes only a few of the methods that will be needed. You are required to implement this design. See image.
Notes on the design:
1. Class QuizQuestion is an abstract class and its administer method is an abstract method.
2. Class QuizAnswer is an abstract class.
3. The value for attribute type is
4. Attribute result can take value C for correct or I for incorrect.
5. The readQuestion method is a static method which reads a question from a le and returns a new question object of appropriate type. This method assumes that the cursor is at the very start of the question befre the execution of the method. And after the execution, it must leave the cursor at the beginning of the next record (if one exists). The format of the text le is described on pages 5 and 6.
6. The administer method is a method which displays the question to the user, collects the users answer and returns a new answer object of the appropriate type.
Task 1
Implement the classes in the design.
Write a test program, called QuizQuestionTester.java, to test those classes. The program should
Task 2
Write a tester program, called ReadAdministerQuestions.java, to
The format of the text le is shown in the example below.
T
try/catch blocks can be nested.
+ true
.
M
What is the keyword used to declare a class to be a subclass of another class?
- implements
+ extends
- subclass
- interface
.
W
What is the key word for constant?
+ final
.
W
ArithmeticException is a/an _____ exception. Fill in the blank.
+ unchecked
.
For the rst question,
For the second question,
For the third question,
For the fourth question, the details are given similarly to the third question. But note that Fill in the blank is part of the question text on the second line.
The tester program (of Task 2) should present the questions to the user and get the answers as shown in th example below:
QUESTION 1:
A checked exception must be caught or declared.
True or false?
Type true or false in lower case: true
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
Type a letter between a and d inclusive: b
QUESTION 3:
What is the key word for constant?
Type in your answer (use capital letters only when necessary): final
QUESTION 4:
ArithmeticException is a/an exception. Fill in the blank.
Type in your answer (use capital letters only when necessary): checked