public InputData GetInputData()
        {
            var inputStringData = new InputStringData();

            Console.WriteLine("What is array height?");
            inputStringData.Height = Console.ReadLine();

            Console.WriteLine("What is array width?");
            inputStringData.Width = Console.ReadLine();

            Console.WriteLine("How many moves?");
            inputStringData.MoveCounter = Console.ReadLine();

            Console.WriteLine("How many alive cells are there in initial state?");
            int.TryParse(Console.ReadLine(), out var aliveCounter);


            if (aliveCounter > 0)
            {
                Console.WriteLine("Write alive cells coordinates. Input format: heightIndex widthIndex");
                for (int i = 0; i < aliveCounter; i++)
                {
                    inputStringData.Cells.Add(Console.ReadLine());
                }
            }

            var result = new InputData(inputStringData);

            return(result);
        }
Exemplo n.º 2
0
        public InputData(InputStringData inputStringData)
        {
            int.TryParse(inputStringData.Height, out var height);
            int.TryParse(inputStringData.Width, out var width);
            InitialStateArray = new int[height, width];

            int.TryParse(inputStringData.MoveCounter, out var moves);
            MoveCounter = moves;

            foreach (var cell in inputStringData.Cells)
            {
                var coordinates = cell.Split(' ').Select(x => int.Parse(x ?? "0")).ToArray();
                InitialStateArray[coordinates[0], coordinates[1]] = 1;
            }
        }