Exemple #1
0
        public void Play()
        {
            gameLogic = new FarmerGame();
            string move = "";

            do
            {
                DisplayGameState();
                string result = PromptForMove(move);
                DisplayGameState();
                ProcessChoice(result);
                bool hasWon = gameLogic.DetermineWin();

                if (hasWon == true)
                {
                    Console.WriteLine("You have WON the game!");
                    return;
                }
                if (gameLogic.AnimalAteFood() == true)
                {
                    gameLogic.GameOver();
                    return;
                }
            } while (gameLogic.AnimalAteFood() == false);
        }
        //controlling Loop
        public void Play()
        {
            thegame = new FarmerGame(); //new game.
            DisplayWelcome();

            Console.WriteLine("Press any key to continue...");
            Console.WriteLine();
            Console.ReadKey();

            while (!thegame.GameOver())
            {
                DisplayGameState();
                ProcessChoice(PromptForMove());

                if (thegame.AnimalAteFood())
                {
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    Console.WriteLine("You lost the game, since animal ate the food");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                }

                if (thegame.DetermineWin())
                {
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("You won the game !!! ");
                    Console.ForegroundColor = ConsoleColor.White;
                    break;
                }
            }
        }
Exemple #3
0
        /*static void DisplayWelcome()
        {
            Console.WriteLine("Welcome to the Farmer Game - a test of logic!");
            Console.WriteLine();
            Console.WriteLine("The goal as the Farmer is to move all your");
            Console.WriteLine("goods - the fox, the chicken, and the grain -");
            Console.WriteLine("to the other side of the river without losing it.");
            Console.WriteLine();
            Console.WriteLine("Press enter to play!");
            Console.ReadLine();
            Console.Clear();
        }*/
        public void Play()
        {
            gameLogic = new FarmerGame();
            string move = "";
            do
            {
                DisplayGameState();
                string result = PromptForMove(move);
                ProcessChoice(result);
                bool hasWon = gameLogic.DetermineWin();

                if (hasWon == true)
                {
                    Console.WriteLine("You have WON the game!");
                    return;
                }
                if (gameLogic.AnimalAteFood() == true)
                {
                    gameLogic.GameOver();
                    return;
                }
            }while (gameLogic.AnimalAteFood() == false);
        }
Exemple #4
0
 void PlayGame()
 {
     gameLogic = new FarmerGame();
     bool hasWon = gameLogic.DetermineWin();
     if (gameLogic.AnimalAteFood() == true)
     {
         gameLogic.GameOver();
         return;
     }
 }