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:
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
Word questions
For this type of question, the users answer consists of one or more words. Two examples are shown below. In the first example, a question is asked. In the second example, a blank in a statement is to be filled in.
What is the key word to define constants?
Type in your answer: final
ArithmeticException is a/an _____ exception. Fill in the blank.
Type in your answer: checked
As illustrated, the program displays
An answer may be case-sensitive or not. The answer to the first question in the example above is case-sensitive. Thus, the answer Final, for example, will marked as being incorrect. Whereas, for the second question, the answer UNchecked, for example, will be marked as correct.
Multiple choice questions
The interaction for a multiple choice question is as shown in the examples 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 in a string of letters from a to d (in alphabetical order): b
Which of the following are keywords to specify access level?
choices:
a) public
b) protected
c) package
d) private
e) local
Type in a string of letters from a to e (in alphabetical order): abd
As illustrated, the program displays
Note carefully that there may be more than one correct choice for a question (as for the second question above).
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:
Implement the classes in the design.
Write a test program, called QuizQuestionTester.java, to test those classes. The program should
To maintain collections, you can use container classes from the Java library, such as ArrayList. If you choose to use array, you can assume that we can have at most 100 questions in a quiz test, and at most 10 possible choices for a multiple choice question.
Write a tester program, called ReadAdministerQuestions.java, to
Read a number of questions from a text file (Questions.txt) and store them in list of QuizQuestion objects. (See the description of the file format given below.)
This method assumes that
In other words, thinking of the text file as consisting of several records, each of which spec- ifies a question, with the dot as the termination of the record, we can state the requirements above as follows;
Display the quiz questions on the screen. Using the toString method for this task would be acceptable.
Administer the test (present the questions and get the answer) and store the answers in a list of QuizAnswer objects. (See the program-user interaction described below.)
Display the QuizAnswer objects in the list. Using the toString method for this task would be acceptable.
The format of the text file is shown in the example below.
T
try/catch blocks can be nested.
+ true
.
W
ArithmeticException is a/an _____ exception. Fill in the blank.
+ unchecked
.
W
What is the key word to define constants?
+ final//CS
.
M
What is the keyword used to declare a class to be a subclass of another class?
- implements
+ extends
- subclass
- interface
.
M
Which of the following are keywords to specify access level?
+ public
+ protected
- package
+ private
- local
.
For the first question,
For the second question,
The third question is similar to the second one, but the correct answer is given by the line
+ final//CS
in which the tag //CS is used to indicate that the answer (which is final) is case-sensitive.
For the fourth question,
The fifth question is similar to the fourth one, but it has several correct choices, as indicated by several plus signs. The correct answer for this question is required to be abd, not adb for example.
The tester program (of Task 2) should present the questions to the user and get the answers as shown in the example below:
QUESTION 1
try/catch blocks can be nested.
Type true or false: true
QUESTION 2
ArithmeticException is an _____ exception. Fill in the blank.
Type your answer: unchecked
QUESTION 3
What is the key word to define constants?
Type your answer: final
QUESTION 4
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 in a string of letters from a to d (in alphabetical order): b
QUESTION 5
Which of the following are keywords to specify access level?
a) public
b) protected
c) package
d) private
e) local
Type in a string of letters from a to e (in alphabetical order): abd
// followed by the display of the QuizAnswer objects