-
Title:
The Quiz Hierarchy - Intro to Java Programming
-
Description:
-
And the car hierarchy you've just seen, makes it easy to understand the
-
concepts of super and sub classes but it doesn't make for a very interesting
-
implementation, instead lets look at quizzes. In a quiz, you can have different
-
kinds of questions so it's natural to have a super class question. And then,
-
you may have various sub classes. Maybe a question where you need to fill in a
-
missing word, or a question where you're given a bunch of choices, or one where
-
you've to supply a number, but it might be okay if it's not exactly the right
-
answer. A numeric question might take round off into account. And so on. You
-
could even think that there is a, sub-class of choice question. I'll call it a
-
Multi Choice Question, you know, one of those where you need to supply all of
-
the choices that are correct. What do our questions have in common? They all
-
need to be able to display themselves, and the display may be as simple as
-
showing the question text, or it might have to have a list of choices. Or an
-
underscore at the right place for filling in a word, and also any question
-
needs to be able to check its answer. That might be a string comparison or a
-
number comparison that's, or a number comparison after some accuracy. So the
-
idea is that, the super-class question will give reasonable implementations of
-
these methods, and the sub-classes can modify them if they don't work for the
-
context of the sub-classes. I've implemented the question class for you, and
-
here is a programming problem that's designed to make you familiar with that
-
class. So that you can form sub-classes, as we go, go along. Here's the
-
question class. Have a look at it's methods, as you answer the next programming
-
question. And here is a demo program, in which I want you to fill in some
-
details. Make a question object, and then there is a method present question.
-
That displays a question, gets the user response, checks whether was correct.
-
They're methods for displaying and for checking a response. And I want you to
-
look them up and call them.