Question: Use java Implement the Strategy pattern for quizzes/exams that have multiple types of questions. This assignment focuses on following the pattern, so dont worry about

Use java

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: 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

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!