Question
Use java and display the screenshot using the example as mentioned as below(for class Quiz, please use your own example to illustrate) Implement the Strategy
Use java and display the screenshot using the example as mentioned as below(for class Quiz, please use your own example to illustrate)
Implement the Strategy pattern for quizzes/exams that have multiple types of questions.
- This assignment focuses on following the pattern, so dont worry about error-checking (like case sensitivity, whether there are any underscores in a FillIn question)
- You need to implement the following in the package school
- Question: the Strategy interface for this assignment
- Placed in the package school.assessment
- This interface has a function mark(String ans) that returns true if its parameter is the correct answer, false if not
- MultipleChoice: a concrete child class of Question
- The constructor takes 3 parameters:
- The String text to display to the user taking the quiz/exam
- Ex: On which continent is the country of India?
- A List
for the possible answers to display - Ex: {Asia, Africa, Europe}
- A String for the correct answer
- Ex: Asia
- The String text to display to the user taking the quiz/exam
- The ans parameter for mark() is the answer chosen by a test taker, and mark() compares it to the correct answer set in the constructor
- Override toString() to return a String with the text followed by each possible answer on a separate line
- The constructor takes 3 parameters:
- FillIn: a concrete child class of Question
- The constructor takes 2 parameters:
- The String text to display to the user taking the quiz/exam
- Ex: The university is in the city of _______
- A String for the correct answer
- Ex: Jersey City
- The String text to display to the user taking the quiz/exam
- The mark()returns true if the parameter equals the correct answer, false if not
- Override toString() to return a String with the text to display
- The constructor takes 2 parameters:
- Quiz: a concrete class that contains a bunch of Question objects. It supports:
- void add(Question question) to add a question to the quiz
- int grade(List
answers) to return the number of correct answers in the parameter
- Question: the Strategy interface for this assignment
Style-wise,
Use good names
Name any constants you use, and use those names
Please take advantage of your development environment to indent the code nicely.
Include a comment at the top of each file that includes the purpose of the file, plus a comment for each class and function to describe its purpose, the purpose of each parameter and the return value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started