예제 #1
0
        static void Main(string[] args)
        {
            GuessGameEngine gameEngine = new GuessGameEngine();
            RandomGenerator ran = new RandomGenerator();
            ran.StartPoint = 50;
            ran.EndPoint = 100;
            gameEngine.randomGenerator = ran;
            gameEngine.startGame();

            Console.WriteLine("Enter number between 1 - 100");
            while (true)
            {
                int userInput = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(gameEngine.verifyGuess(userInput));

                if (gameEngine.isGameEnded)
                {
                    Console.WriteLine("Do you want to continue?");
                    var vote = Console.ReadLine().ToString();

                    if (vote.ToLower() == "yes")
                    {
                        Console.WriteLine("Enter number between 1 - 100");
                        gameEngine.restart();
                    }
                    else
                        break;
                }
            }

            Console.ReadKey();
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["GameEngine"] == null)
            {
                engine = new GuessGameEngine();
                engine.startGame();
            }
            else
                engine = (GuessGameEngine)Session["GameEngine"];

            if (!String.IsNullOrEmpty(txtInput.Text))
                lblOutput.Text += txtInput.Text + " " + engine.verifyGuess(Convert.ToInt32(txtInput.Text)) + "<br/>";

            if (!Page.IsPostBack)
                lblOutput.Text += "Enter value between 1-100<br/>";

            txtInput.Text = "";
            txtInput.Focus();

            Session["GameEngine"] = engine;
        }