Beispiel #1
0
        /// <summary>
        /// Read data from console until entered line is empty. Setup test cases.
        /// </summary>
        static void SetupData()
        {
            // Setup Plateau Borders
            string plateauBorders = Console.ReadLine();

            PLATEAU_UPPER_BOUNDRY_BORDER_X = int.Parse(plateauBorders.Split(' ')[0]);
            PLATEAU_UPPER_BOUNDRY_BORDER_Y = int.Parse(plateauBorders.Split(' ')[1]);

            // Create movement strategy for rovers
            BorderStrategy borderStrategy = new ThrowExceptionBorderStrategy(PLATEAU_LOWER_BOUNDRY_BORDER_X, PLATEAU_LOWER_BOUNDRY_BORDER_Y, PLATEAU_UPPER_BOUNDRY_BORDER_X, PLATEAU_UPPER_BOUNDRY_BORDER_Y);

            while (true)
            {
                string roverInfo = Console.ReadLine();

                if (string.IsNullOrEmpty(roverInfo))
                {
                    break;
                }

                // Create new rover and set movement strategy
                Rover  rover           = Rover.GetNewRover(int.Parse(roverInfo.Split(' ')[0]), int.Parse(roverInfo.Split(' ')[1]), roverInfo.Split(' ')[2].ToCharArray()[0], borderStrategy);
                string commandSequence = Console.ReadLine();

                // Create case. Assign command sequence to rover
                cases.Add(rover, commandSequence);
            }
        }