7.9. Studio: Fun with Quizzes

For this studio, you will design and build a console program that allows the user to take a quiz. This means you will have to create some questions, and get some input from the user.

First, the questions. We want to be able to handle multiple types of questions:

  1. Multiple choice: a question with a fixed set of possible answers, of which only one may be chosen and only one answer is correct

  2. Checkbox: a question with a fixed set of possible answers, of which any number may be chosen; there is one correct combination of choices

  3. True/False: a question that has a true/false answer

7.9.1. Design

In order to design your program, consider:

  1. What do these types of questions have in common?

  2. What makes these question types different?

First, design a base class (called Question) that contains the common features, and design subclasses for each of the question types. For each question type be sure to include:

  1. Class name

  2. Fields and properties with access modifiers

  3. Methods with access modifiers

  4. Any inheritance relationship

Should any of the question classes be abstract? If so, should any of its methods be abstract?

Make sure that there is functionality included to display the questions, to display the possible answers, and to check to see if the answer(s) is correct.

Then design the Quiz class. A quiz has a list of questions, and we should be able to:

  1. Add questions

  2. Run or carry out the quiz

  3. Grade the quiz

7.9.2. Implementation

Create a new IntelliJ project and implement the design that you created. If you are unsure about your design, get some feedback by talking through it with a classmate before you start coding.

7.9.3. Putting it all together

Create a class named QuizRunner with only a main method. The program should create several questions, present them to the user, accept the user’s responses, and then tell them whether their answers were correct or incorrect.

7.9.4. How to Submit

Push up your work to a new Github repository. Submit the link to your repository in the Lesson 6 Studio assignment in Canvas.

7.9.5. Bonus Missions

  1. Add a short answer question type that includes validation behavior to only allow the user to enter text with less than 80 characters.

  2. Add a couple of more question types to your program:

    1. Linear scale: a question that allows the user to provide a numeric response within an integer scale, which may vary from question to question. For instance, it could be 1-3 for one linear scale question, and 1-5 for another.

    2. Paragraph: Similar to short answer but allows for responses of up to 500 characters.

  3. Add tests with JUnit to your classes.