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

  • SEARCH
  • Home
  • 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 7513257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:07:29+00:00 2026-05-30T00:07:29+00:00

I’m sorry for the title, I wasn’t sure what to call it. My problem

  • 0

I’m sorry for the title, I wasn’t sure what to call it.

My problem is this, I have a switch statement which randomly chooses a question type as so:

questionType[count] = rad.nextInt(4);

        switch (questionType[count])
        {
        case 0:

                questionArray[count] = new Times(count + 1);
                ((Times) questionArray[count]).askQuestion(question);
                break;

        case 1:

                questionArray[count] = new Add(count + 1);
                ((Add) questionArray[count]).askQuestion(question);
                break;

        case 2:

                questionArray[count] = new Minus(count + 1);
                ((Minus) questionArray[count]).askQuestion(question);
                break;

        case 3:

            questionArray[count] = new Divide(count + 1);
            ((Divide) questionArray[count]).askQuestion(question);
            break;

        }

What this does is randomly choose a question and then add it to the next array, here is the pesudocode version:

questionType = random(4)

case questionType == 0
do something
break

case questionType == 1
do something
break

case questionType == 2
do something
break

case questionType == 3
do something
break;

Now lets say I do not want any 1’s or 2’s, how do I put that into effect? I was thinking something along the lines of this:

 START:

     questionType = random(4)


        case questionType == 0
    if(0 enabled)
    {
        do something

        break
    }

        case questionType == 1
    if(1 enabled)
    {
        do something
        break
    }

        case questionType == 2
    if(2 enabled)
    {
        do something
        break
    }


        case questionType == 3
    if(3 enabled)
    {
        do something
        break;
    }
else goto start

But this is very inefficient code and uses a goto, what are the alternatives?

  • 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-30T00:07:31+00:00Added an answer on May 30, 2026 at 12:07 am

    A few ways of implementing but
    if you had a store of questions, and whether they were enabled.
    Then extract enabled from that and use it’s count as the argument for rad.
    so you enabled Questions would be 3 & 4 but would occupy positions 0 & 1 in the list of enabled questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have some data like this: 1 2 3 4 5 9 2 6
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.