static void Main(string[] args) { Plateau plateau = new Plateau(5, 5); Rover rover = new Rover(1, 2, "N", plateau); Rover rover2 = new Rover(3, 3, "E", plateau); rover.ReadCommands("LMLMLMLMM"); rover2.ReadCommands("MMRMMRMRRM"); Console.WriteLine(rover.toString()); Console.WriteLine(rover2.toString()); Console.ReadLine(); }
public Rover(int x, int y, String direction, Plateau plateau) { if (x >= 0 && y >= 0 && x <= plateau.X && y <= plateau.Y) { this.plateauRoverPositionX = x; this.plateauRoverPositionY = y; } else { throw new OutOfBoundsException("Invalid value!. It musn't negative."); } if (direction.Equals("N") || direction.Equals("S") || direction.Equals("E") || direction.Equals("W")) { this.direction = direction; } else { throw new InvalidStringValueException("Invalid value string is empty or null."); } this.plateau = plateau; }