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. A user can only select one answer and only one answer is correct.
  2. Checkbox: A question with a fixed set of possible answers. A user can select any number of answers and 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 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 Visual Studio console 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

In the Main method within Program, the project 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. Commit Your Work

Push up your work to a new Github repository.

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 a short answer, allows for responses of up to 500 characters.
  3. Test your non-abstract classes with a new MSTest project.