Here's another way of thinking about the problem - are there any differences at all between MathQuestion and WordQuestion? For me, it sounds like they are both objects of a Question, and you can distinguish between different types with composition .
Enum, , ( , ActionScript 3 Enums, .)
public class QuestionType {
public static const MATH : QuestionType = new QuestionType("math");
public static const WORLD : QuestionType = new QuestionType("world");
private var _name : String;
public function QuestionType(name : String) {
_name = name;
}
public function toString() : String {
return _name;
}
}
QuestionType :
public class Question {
private var _message : String
private var _answers : Vector.<Answer>;
private var _correctAnswer : Answer;
private var _type : QuestionType;
public function Question(message : String,
answers : Vector.<Answer>,
correctAnswer : Answer,
type : QuestionType) {
_message = message;
_answers = answers.concat();
_correctAnswer = correctAnswer;
_type = type;
}
public function getType() : QuestionType {
return _type;
}
}
, (, Question) :
public class QuizView extends Sprite {
public function displayQuestion(question : Question) : void {
switch(question.type) {
case QuestionType.WORLD:
_backgroundClip.gotoAndStop("world_background");
break;
case QuestionType.MATH:
_backgroundClip.gotoAndStop("math_background");
break;
}
}
}