Search code examples
javaoopmodeling

How to model a quiz-system in OOP?


I am just trying to make a quiz system for young people to learn road/traffic signs.The idea was also to make something in a way that i later can use the same system for other types of quizzes.

I have just started out, and this is what i have planned so far: (I am doing this in Java)

  • Class named Roadsign (name, type, description)
  • Class named Question (Roadsign, answer, options)
  • Class named Quiz (ArrayList, number of right answers, and so on..)

The idea is that i eventually can use any model, not just Roadsign, inside the Question class. Maybe it also can be done in such a way that you decide inside the Question class what attribute/member of the model class you wish to use as the answer.

I am unsure on how i would model such a system, especially on behalf of the Question class.

Hopes this makes sense, and that someone wants to share me some good ideas :)


Solution

  • If you want to model a quiz system where each question consists of an image (in your case Roadsign), a question and answer options, you could do it like that:

    • Class named QuestionImage(name, description)
    • Class named Question (QuestionImage, question, answer, options)
    • Class named Quiz (ArrayList, number of right answers, and so on..)

    Each question could then have an image, a question (so that you can also ask questions unlike What does the image show?), one right answer, and several wrong answers.