예제 #1
0
        private void PlayGame()
        {
            int maxInput = 0;

            do
            {
                do
                {
                    maxInput = CreateScreen();                                                        //create user screen and get nort and southbank sizes

                    getSelectionBool = int.TryParse(Console.ReadLine(), out getSelection);            // try parse user input
                } while (getSelectionBool == false || getSelection <= 0 || getSelection >= maxInput); //end inner do loop

                logic.MoveItem(getSelection);                                                         //rearange north and southbank lists
            } while (logic.checkStateOfCharacters(logic.NorthBank, logic.SouthBank)[0] == 0);         //end outter do loop

            winnerLooser = logic.checkStateOfCharacters(logic.NorthBank, logic.SouthBank);

            switch (winnerLooser[0])
            {
            case 1:             // user won
                Console.Clear();
                CreateScreen(); //create user screen
                Console.WriteLine("\nYou've Won!!! The Farmer thanks you.....");

                break;

            case 2:             // user lost
                Console.Clear();
                CreateScreen(); //create user screen
                Console.Write("\n\nYou lost!!!");
                if (winnerLooser[1] == 0)
                {
                    Console.Write(" The Chicken ate the Grain. Then the Fox ate the Chicken.\n");
                }
                if (winnerLooser[1] == 1)
                {
                    Console.Write(" The Fox ate the Chicken.\n");
                }
                else if (winnerLooser[1] == 2)
                {
                    Console.Write(" The Chicken ate the Grain.\n");
                }
                break;
            }//end switch

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }//end playGame()