Beispiel #1
0
 private static void MoveEvil(Evil evil, int[,] matrix)
 {
     while (evil.Row >= 0)
     {
         int n = matrix.GetLength(0);
         int m = matrix.GetLength(1);
         if (evil.Row < n && evil.Col >= 0 && evil.Col < m)
         {
             matrix[evil.Row, evil.Col] = 0;
         }
         evil.UpdateCoordinates(evil.Row - 1, evil.Col - 1);
     }
 }
Beispiel #2
0
        private static void UpdateCoordinates(string command, Ivo ivo, Evil evil)
        {
            var ivoCoordinates = command.Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                 .Select(int.Parse).ToArray();

            ivo.UpdateCoordinates(ivoCoordinates[0], ivoCoordinates[1]);

            command = Console.ReadLine();

            var evilCoordinates = command.Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                  .Select(int.Parse).ToArray();

            evil.UpdateCoordinates(evilCoordinates[0], evilCoordinates[1]);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            short[] sizes = Console.ReadLine()
                            .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                            .Select(short.Parse)
                            .ToArray();

            var matrix = InitializeMatrix(sizes);
            var ivo    = new Ivo();
            var evil   = new Evil();

            string command;

            while ((command = Console.ReadLine()) != "Let the Force be with you")
            {
                UpdateCoordinates(command, ivo, evil);
                MoveEvil(evil, matrix);
                MoveIvo(ivo, matrix);
            }

            Console.WriteLine(ivo.Score);

            Console.ReadKey();
        }