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 3798730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:37:09+00:00 2026-05-19T13:37:09+00:00

Okay, I have a goal right now to make a basic text adventure. To

  • 0

Okay, I have a goal right now to make a basic text adventure. To do this, however, I would need/want to have a switch statement that can do the following:

  • Check to see if a string has a word SOMEWHERE inside.
  • Check to see if a string has two words in any combination somewhere inside.

How would I accomplish this? Could you show me coding for this specific example:

A user is prompted for data. A switch statement checks for “look box” as one case, and “sleep” as another. The program doesn’t care what order any words are in, but does care about the order of the letters.

Please explain everything in detail. I just started coding.

EDIT: Thank you for all the answers. I understand there are better, more complicated, and more useful ways of handling this, but it just isn’t at my level yet.

  • 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-19T13:37:10+00:00Added an answer on May 19, 2026 at 1:37 pm

    Here’s another idea:

        string input = "look at the sleep box";
        bool caseA = input.Contains("sleep");
        bool caseB = input.Contains("look") && input.Contains("box");
    
        int scenarioId;
        if (caseA && caseB)
            scenarioId = 1;
        else if (caseA)
            scenarioId = 2;
        else if (caseB)
            scenarioId = 3;
        // more logic?
        else
            scenarioId = 0;
    
        switch (scenarioId)
        {
            case 1:
                Console.WriteLine("Do scenario 1");
                break;
            case 2:
                Console.WriteLine("Do scenario 2");
                break;
            case 3:
                Console.WriteLine("Do scenario 3");
                break;
            // more cases
            default:
                Console.WriteLine("???");
                break;
        }
    

    It uses if/then/else to assess a particular scenario including potential combinations such as input like "look at the sleep box" and then uses a switch statement to execute accordingly.

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

Sidebar

Related Questions

Okay, I have this program and I don't want more than one instance of
Okay so I want to make an application that launches other applications. However, the
Okay i have this problem with every page i make. im not sure what
Okay I have been trying to get this to work for some time now.
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay, this is just a crazy idea I have. Stack Overflow looks very structured
Okay this is a real headscratcher. I have an application which calls a web
Okay this is a homework question, and I just don't have a clue how
I would like to have a confirmation on some point. My goal is to
Okay. I'm sick of this problem. This has to have an easy fix, I'm

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.