Take for example a multiple choice question game.
You have a MathQuestion and WordQuestion classes, should these implement an IQuestion interface, that defines say a question, answer, and difficulty functions OR is it more usual to extend a question base class, and override these functions?
Which is the more correct way of doing such things?
Here’s another way of thinking about the problem – is there actually any different between a MathQuestion and a WordQuestion? To me, it sounds like they are both Question objects and you could differentiate between the different types via composition.
You could start by defining an Enum class which lists the different types of Questions which appear in your Quiz (strictly speaking ActionScript 3 does not have proper Enums, but we can still achieve type safety with the following code.)
You can then pass one of the QuestionType constants to the Question Class when you construct it:
Finally, a client (the code which makes use of the Question object) can query the question type easily: