Beispiel #1
0
 public void TestMethodVerificaCella()
 {
     Cellula cellula = new Cellula();
     Tabella grid = new Tabella(3, 3);
     grid = cellula.VerificaCelle(grid);
     bool[,] ris = new bool[3, 3];
     ris[0, 0] = true;
     ris[0, 1] = true;
     ris[0, 2] = false;
     ris[1, 0] = true;
     ris[1, 1] = true;
     ris[1, 2] = false;
     ris[2, 0] = false;
     ris[2, 1] = false;
     ris[2, 2] = false;
     CollectionAssert.AreEqual(ris, grid.Celle, "Metodo 'VerificaCelle' non riuscito");
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            int n = 3;
            char[,] tabellalife = new char[n, n];
            Tabella grid = new Tabella(n, n);
            Cellula cellula = new Cellula();

            Tabella gridris = grid;

            for (int i = 0; i < 10; i++)
            {
                ScorriEScriviCella(gridris);
                grid = gridris;
                gridris = cellula.VerificaCelle(grid);
            }

            #region Roba Vecchia
            //for (int i = 0; i < tabellalife.GetLength(0); i++)
            //{
            //    for (int j = 0; j < tabellalife.GetLength(1); j++)
            //    {
            //        if (gridris.Celle[i, j])
            //            tabellalife[i, j] = 'x';
            //        else
            //            tabellalife[i, j] = '.';
            //        Console.Write(tabellalife[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("----------------------------------------------------------------");
            //grid = gridris;

            //gridris = cellula.VerificaCelle(grid);
            //for (int i = 0; i < tabellalife.GetLength(0); i++)
            //{
            //    for (int j = 0; j < tabellalife.GetLength(1); j++)
            //    {
            //        if (gridris.Celle[i, j])
            //            tabellalife[i, j] = 'x';
            //        else
            //            tabellalife[i, j] = '.';
            //        Console.Write(tabellalife[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("----------------------------------------------------------------");
            //grid = gridris;

            //gridris = cellula.VerificaCelle(grid);
            //for (int i = 0; i < tabellalife.GetLength(0); i++)
            //{
            //    for (int j = 0; j < tabellalife.GetLength(1); j++)
            //    {
            //        if (gridris.Celle[i, j])
            //            tabellalife[i, j] = 'x';
            //        else
            //            tabellalife[i, j] = '.';
            //        Console.Write(tabellalife[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("----------------------------------------------------------------");
            //grid = gridris;

            //gridris = cellula.VerificaCelle(grid);
            //for (int i = 0; i < tabellalife.GetLength(0); i++)
            //{
            //    for (int j = 0; j < tabellalife.GetLength(1); j++)
            //    {
            //        if (gridris.Celle[i, j])
            //            tabellalife[i, j] = 'x';
            //        else
            //            tabellalife[i, j] = '.';
            //        Console.Write(tabellalife[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("----------------------------------------------------------------");
            //grid = gridris;

            //gridris = cellula.VerificaCelle(grid);
            //for (int i = 0; i < tabellalife.GetLength(0); i++)
            //{
            //    for (int j = 0; j < tabellalife.GetLength(1); j++)
            //    {
            //        if (gridris.Celle[i, j])
            //            tabellalife[i, j] = 'x';
            //        else
            //            tabellalife[i, j] = '.';
            //        Console.Write(tabellalife[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("----------------------------------------------------------------");
            #endregion

            Console.Read();
        }