Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5934157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:04:29+00:00 2026-05-22T15:04:29+00:00

Take for example a multiple choice question game. You have a MathQuestion and WordQuestion

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:04:30+00:00Added an answer on May 22, 2026 at 3:04 pm

    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.)

    public class QuestionType {
        public static const MATH : QuestionType = new QuestionType("math");
        public static const WORLD : QuestionType = new QuestionType("world");
    
        private var _name : String;
    
        // Private constructor, do no instantiate new instances.
        public function QuestionType(name : String) {
            _name = name;
        }
    
        public function toString() : String {
            return _name;
        }
    } 
    

    You can then pass one of the QuestionType constants to the Question Class when you construct it:

    public class Question {
        private var _message : String /* Which country is Paris the capital of? */
        private var _answers : Vector.<Answer>; /* List of possible Answer objects */
        private var _correctAnswer : Answer; /* The expected Answer */
        private var _type : QuestionType; /* What type of question is this? */
    
        public function Question(message : String, 
                                  answers : Vector.<Answer>, 
                                  correctAnswer : Answer, 
                                  type : QuestionType) {
            _message = message;
            _answers = answers.concat(); // defensive copy to avoid modification.
            _correctAnswer = correctAnswer;
            _type = type;
        }
    
        public function getType() : QuestionType {
            return _type;
        }
    }
    

    Finally, a client (the code which makes use of the Question object) can query the question type easily:

    public class QuizView extends Sprite {
        public function displayQuestion(question : Question) : void {
            // Change the background to reflect the QuestionType.
            switch(question.type) {
                case QuestionType.WORLD:
                    _backgroundClip.gotoAndStop("world_background");
                    break;
    
                case QuestionType.MATH:
                    _backgroundClip.gotoAndStop("math_background");
                    break;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, let's take the format of a forum, where we have multiple users
Take the example classes below. I want to display the customer and two addresses
Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
I have a ListView with multiple choice entries where some are checked from the
Take my profile for example, or any question number of views on this site,
I have a program where I have multiple classes derived from a base class.
The questions says everything, take this example code: <ul id=css-id> <li> <something:CustomControl ID=SomeThingElse runat=server
I've convinced myself that they can't. Take for example: 4 4 + 4 /
How to get the relative path in t sql? Take for example a .sql
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.