Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago