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 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
    • 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 mark()returns true if the parameter equals the correct answer, false if not
      • Override toString() to return a String with the text to display
    • 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!