コード例 #1
0
ファイル: Program.cs プロジェクト: AdBon88/kata-game-of-life
        private static void SetUpGridStartingState()
        {
            string nextInput;

            Console.WriteLine();
            Console.WriteLine(Output.PromptForCoordsToToggle);
            do
            {
                Console.WriteLine();
                Console.WriteLine(Output.CurrentGridHeader);
                Console.WriteLine(GridFormatter.OutputWithGridLinesAndNumbers(_grid));
                nextInput = GetNextCoordsFromUser();
                if (nextInput == "")
                {
                    continue;
                }
                if (InputValidator.TryParseCoords(nextInput, _grid, out var cellCoordToToggle))
                {
                    _grid.ToggleCellAliveAtCoords(cellCoordToToggle);
                }
                else
                {
                    Console.WriteLine();
                    Console.Write(Output.InvalidCoords);
                }
            } while (nextInput != "");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: AdBon88/kata-game-of-life
        private static void StartSimulation(Game game)
        {
            var cki = new ConsoleKeyInfo();

            Console.WriteLine();
            Console.WriteLine(Output.StartingSimulation);
            while (cki.Key != ConsoleKey.Escape)
            {
                Console.WriteLine(GridFormatter.OutputWithoutGridLinesAndNumbers(_grid));
                Console.WriteLine();
                Console.WriteLine(Output.PromptToProgressTime);
                cki = Console.ReadKey();
                game.ProgressTime();
            }
        }