Write a program that asks the user quiz questions. You can keep the interface simple, because it is (of course) all about the data model in this assignment. You will implement several types of quiz questions, each of which must be called in the same way.
The task is to create the (abstract) class Question
and its subclasses. The following types of questions are possible in the program:
ChoiceQuestion
- A question with multiple answers of which only 1 is correct.NumericalQuestion
- A mathematical question where you have to enter the correct answer (as int).TrueFalseQuestion
- A question where the answer consists of ‘true’ or ‘false’.A few tips to get you started:
Question
where you should think about how the question text is retrieved and how the answer can be checked.int
.Question
should be able to show the question text and is able to check the answer, similarly to what you did a few weeks ago.Quiz
class could be useful to manage the actual game aspect of the exercise.****** Question 1 ******
This is a question you need to perform a calculation. Please enter the right answer of:
What is the value of 2+2?
Your answer: 4
That answer is correct!
****** Question 2 ******
This is a simple true or false question. Do you agree with the following statement?
Abstract classes can be instantiated into objects
Please select your answer:
1) True
2) False
Your answer: 2
That answer is correct!
****** Question 3 ******
This is a question where you must select 1 option from a list of choices. Please answer the following question:
What programming language do we use in this course?
Please select your answer:
1: C++
2: Java
3: PHP
4: Fortran
Your answer: 2
That answer is correct!
****** Question 4 ******
This is a question where you must select 1 option from a list of choices. Please answer the following question:
What is your favorite course (this quartile)?
Please select your answer:
1: Object Oriented Programming
2: Something else
3: Some weird course
4: I can't think of any more options :-)
Your answer: 4
That answer is INCORRECT!
Your final score was 4 out of 8 questions.