English subtitles

← The Quiz Hierarchy - Intro to Java Programming

Get Embed Code
6 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

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