Beispiel #1
0
 private static void FillTheMatrix(char[][] matrix, int rows, int columns, ref int playerRow,
                                   ref int playerCol, List <Bunny> bunniesList)
 {
     for (int row = 0; row < rows; row++)
     {
         var rowInput = Console.ReadLine().ToCharArray();
         if (rowInput.Contains('P'))
         {
             playerRow = row;
             playerCol = Array.IndexOf(rowInput, 'P');
         }
         if (rowInput.Contains('B'))
         {
             for (int i = 0; i < rowInput.Length; i++)
             {
                 if (rowInput[i] == 'B')
                 {
                     var currentBunny = new Bunny()
                     {
                         rowB = row, colB = i
                     };
                     bunniesList.Add(currentBunny);
                 }
             }
         }
         matrix[row] = rowInput;
     }
 }
Beispiel #2
0
 private static void FillBunnyList(char[][] matrix, List <Bunny> bunniesList)
 {
     for (int row = 0; row < matrix.GetLength(0); row++)
     {
         for (int col = 0; col < matrix[row].Length; col++)
         {
             if (matrix[row][col] == 'B')
             {
                 var currentBunny = new Bunny()
                 {
                     rowB = row, colB = col
                 };
                 bunniesList.Add(currentBunny);
             }
         }
     }
 }