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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:04:01+00:00 2026-05-24T08:04:01+00:00

I am having difficulty getting the bool done value from EndLoop() and moving it

  • 0

I am having difficulty getting the bool done value from EndLoop() and moving it to the Start() method to end my while loop. What am I doing wrong?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {


        public static void Main(string[] args)
        {
            Start("r");
        }

        public static string Start(string move)
        {

            Console.Write("Welcome to the Shotgun App\nEnter s for single player and m for multiplayer: ");
            string gameType = Console.ReadLine();

            if (gameType == "s")
            {

                Console.Write("Single Player Controls:\n r = reload\n s = shield\n f = fire\nYou start with 1 ammo\nReady to play?");
                Console.ReadLine();

                int ammo = 1;
                int geniusAmmo = 1;
                string geniusMove = "";
                bool done = false;
                while (!done)
                {
                    Console.Write("\nEnter your move: ");
                    move = Console.ReadLine();


                    switch (move)
                    {
                        case "r":
                            Console.Write("\nYou have reloaded, press enter for Genius\n");

                            ammo++;
                            Console.Write("Your ammo is " + ammo);

                            Console.ReadLine();
                            Genius(geniusMove, move, geniusAmmo, done);


                            break;
                        case "s":
                            Console.Write("\nYou have shielded, press enter for Genius\n");

                            Console.Write("Your ammo is " + ammo);

                            Console.ReadLine();
                            Genius(geniusMove, move, geniusAmmo, done);


                            break;
                        case "f":
                            if (ammo != 0)
                            {
                                Console.Write("\nYou have fired, press enter for Genius\n");

                                ammo--;
                                Console.Write("Your ammo is " + ammo);

                                Console.ReadLine();

                                Genius(geniusMove, move, geniusAmmo, done);

                            }
                            else
                            {
                                Console.Write("You don't have enough ammo, try again");
                                done = false;
                            }
                            break;
                        default:
                            Console.Write("\nInvalid move, try again\n");
                            done = false;
                            break;
                    }

                    Console.ReadLine();

                }
                return move;
            }
            else
            {
                return move;
            }
        }

        public static string Genius(string geniusMove, string move, int geniusAmmo, bool done)
        {
            Random RandomNumber = new Random();
            int x = RandomNumber.Next(0,3);
            if (x == 0)
            {
                geniusMove = "f";
                geniusAmmo--;
                Console.Write("Genius had decided to fire.\nGenius ammo is " + geniusAmmo + "\n");
                TestMoves(move, geniusMove);
            }
            else if (x == 1)
            {
                geniusMove = "r";
                geniusAmmo++;
                Console.Write("Genius had decided to reload.\nGenius ammo is " + geniusAmmo + "\n");
                TestMoves(move, geniusMove);
            }
            else if (x == 2)
            {
                geniusMove = "s";  
                Console.Write("Genius had decided to shield.\nGenius ammo is " + geniusAmmo + "\n");
                TestMoves(move, geniusMove);
            }

            return geniusMove;

        }


        public static void TestMoves(string move, string geniusMove)
        {
            bool done = false;
            if (move == "s" && geniusMove == "f")
            {
                Console.Write("Nice shield, no one has died yet");
                EndLoop(move, geniusMove, done);


            }
            else if (move == "f" && geniusMove == "f")
            {
                Console.Write("You both died!  Good game!");
                EndLoop(move, geniusMove, done);


            }
            else if (move == "r" && geniusMove == "f")
            {
                Console.Write("No shield!?  You died!  Good game!");
                EndLoop(move, geniusMove, done);


            }
            else if (move == "f" && geniusMove == "s")
            {
                Console.Write("Genius is too good, no one has died yet");
                EndLoop(move, geniusMove, done);


            }
            else if (move == "f" && geniusMove != "s")
            {
                Console.Write("Genius let his guard down!  Good game!");
                EndLoop(move, geniusMove, done);


            }
            else if (move != "f" && geniusMove != "f")
            {
                Console.Write("Keep playing it safe.");
                EndLoop(move, geniusMove, done);


            }
            else
            {
                EndLoop(move, geniusMove, done);

            }

        }

        public static bool EndLoop(string move, string geniusMove, bool done)
        {

            if (move == "s" && geniusMove == "f")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "s" && geniusMove == "r")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "s" && geniusMove == "s")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "r" && geniusMove == "f")
            {
                done = true;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "r" && geniusMove == "r")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "r" && geniusMove == "s")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "f" && geniusMove == "f")
            {
                done = true;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "f" && geniusMove == "r")
            {
                done = true;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else if (move == "f" && geniusMove == "s")
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
            else
            {
                done = false;
                Console.Write(move + geniusMove + done);
                return done;
            }
        }
    }
}
  • 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-24T08:04:01+00:00Added an answer on May 24, 2026 at 8:04 am

    Declare static bool done = false; in the scope of your class and use the same instead of passing state over the different methods. You could have do that, if you pass the state up to the calling function Start.

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

Sidebar

Related Questions

I'm having great difficulty getting my Android application to play videos from the SD
Am having some difficulty getting an Image from a url, and then displaying it
I am having difficulty getting an integer from a buffer in iOS. To read
I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself
I'm having difficulty getting XQuery to work. I downloaded Saxon-HE 9.2. It seems to
I'm having an extremely difficulty time getting the flowplayer to show up and the
I'm having a lot of difficulty getting strophe's 'attach()' function working. I am working
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
I've been having difficulty getting anything more than a simple index / to return
I am having difficulty getting my page to show up correctly at various browser

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.