コード例 #1
0
        internal void Test()
        {
            IMinerGame test = NewRandomGame("Alina", new Tuple <int, int>(10, 20), 50);

            PrintGame(test);
            test.Start();
            test.OpenCell(0, 0);
            PrintGame(test);
            test.OpenCell(7, 6);
            PrintGame(test);
            test.OpenCell(1, 2);
            PrintGame(test);
            test.OpenCell(8, 8);
            PrintGame(test);
            Console.ReadKey();
        }
コード例 #2
0
ファイル: MinerGameFactory.cs プロジェクト: vbre/tasks_cs2
        internal void Test()
        {
            int Width   = 0;
            int Height  = 0;
            int bombs   = 0;
            int currRow = 0;
            int currCol = 0;

            Console.WriteLine("Hello, I'm a Miner game, please, choose type of game:\nFor Empty game type 0\nFor Random game type 1");
            string typeOfGame = Console.ReadLine();

            Console.WriteLine("Please, enter your name");
            string playerName = Console.ReadLine();

            Console.WriteLine("Please, enter field Width = ");
            Int32.TryParse(Console.ReadLine(), out Width);
            Console.WriteLine("Please, enter field Height = ");
            Int32.TryParse(Console.ReadLine(), out Height);

            switch (typeOfGame)
            {
            case "0":
                IMinerGame emptyGame = NewEmptyGame(playerName, new Tuple <int, int>(Width, Height));
                break;

            case "1":
                Console.WriteLine("Please, specify number of bombs on the field");
                Int32.TryParse(Console.ReadLine(), out bombs);
                IMinerGame randomGame = NewRandomGame(playerName, new Tuple <int, int>(Width, Height), bombs);
                randomGame.Start();
                while (!randomGame.Win && !randomGame.Lose)
                {
                    Console.WriteLine("Choose a cell to open (enter row, that collum)");
                    Int32.TryParse(Console.ReadLine(), out currRow);
                    Int32.TryParse(Console.ReadLine(), out currCol);
                    randomGame.OpenCell(currRow, currCol);
                }
                if (randomGame.Win)
                {
                    Console.WriteLine("{0} the Victory is yours!", playerName);
                }
                else
                {
                    Console.WriteLine("Game over:(");
                }
                break;
            }
        }
コード例 #3
0
ファイル: MinerGameFactory.cs プロジェクト: vbre/tasks_cs2
        internal void Test()
        {
            do
            {
                int row = 5;  // размеры поля   row = 5;
                int col = 4;  //                col = 4;
                int i   = 0;  // координаты открываемой клетки
                int j   = 0;

                IMinerGame game = NewRandomGame("Vladimir", new Tuple <int, int>(row, col), 8);
                game.Start();

                Console.Clear();
                Console.SetCursorPosition(0, 0);

                do
                {
                    Console.Write("Введите, пожалуйста, координату I (целое число от 1 до {0}): ", row);
                    while (!int.TryParse(Console.ReadLine(), out i) || i > row || i < 1)
                    {
                        Console.Write("Попробуйте еще раз. Число должно быть целым от 1 до (включительно) {0}: ", row);
                    }

                    Console.Write("Введите, пожалуйста, координату J (целое число от 1 до {0}): ", col);
                    while (!int.TryParse(Console.ReadLine(), out j) || j > col || j < 1)
                    {
                        Console.Write("Попробуйте еще раз. Число должно быть целым от 1 до (включительно) {0}: ", col);
                    }

                    game.OpenCell(i - 1, j - 1);

                    PrintPole(game);
                }while (game.Win != true && game.Lose != true);
                if (game.Win)
                {
                    Console.WriteLine("Будьте здоровы! Вы выиграли!");
                }
                else if (game.Lose)
                {
                    Console.WriteLine("Попробуйте снова. Увы, этот сет Вы проиграли");
                }

                Console.WriteLine("Для выхода нажмите Escape; для продолжения - любую другую клавишу");
            }while (Console.ReadKey().Key != ConsoleKey.Escape);
        }