Пример #1
0
        public static int Main(string[] args)
        {
            string[] inputLines = File.ReadAllLines(args[0]);
            Plane plane = new Plane();
            for (int row = 0; row < inputLines.Length - 1; row++)
            {
                string line = inputLines[row].Trim('\n');
                int column = 0;
                foreach (var character in line)
                {
                    plane.AddCell(character, column++, row);
                }
            }

            int iterations = 1;
            if (args.Length == 2)
            {
                iterations = int.Parse(args[1]);
            }

            for (int i = 0; i <= iterations; i++)
            {
                Console.WriteLine("{0}\n", plane);
                plane = plane.NextGeneration();
            }

            return 0;
        }
Пример #2
0
 public void NextGenerationCorrectlyGeneratesNextGeneration()
 {
     Plane plane = new Plane();
     plane.AddCell(new Cell(LifeStates.ALIVE, 0, 0));
     plane.AddCell(new Cell(LifeStates.ALIVE, 1, 0));
     Plane nextGen = plane.NextGeneration();
     Assert.AreEqual(0, nextGen.LiveCellCount);
     Assert.AreEqual(0, nextGen.SignificantDeadCellCount);
 }