Example #1
0
        /* When inserting a Rover in the Plateau you need to insert the Position to avoid the Rover to
         * start in a invalid position in the Plateau.
         * Because of that I did not a overload method where you only insert the rover without the Position.
         */
        public void InsertRover(IRover rover, Position roverPosition)
        {
            if (IsValidPosition(roverPosition))
                rover.Position = roverPosition;
            else
                throw new Exception("Invalid coordinates.");

            Rovers.Add(rover);
        }
Example #2
0
 /* It is the responsibility of the Rover to manipulate your own direction and localization.
  */
 public void MoveForward()
 {
     switch (Position.Orientation)
     {
         case Orientation.North:
             Position = Position.IncreaseOneMoreInPositionY();
             break;
         case Orientation.East:
             Position = Position.IncreaseOneMoreInPositionX();
             break;
         case Orientation.South:
             Position = Position.DecreaseOneMoreInPositionY();
             break;
         case Orientation.West:
             Position = Position.DecreaseOneMoreInPositionX();
             break;
     }
 }
Example #3
0
 public bool IsValidPosition(Position position)
 {
     return !(position.PositionX > LengthX || position.PositionY > LengthY);
 }
Example #4
0
 public void Spin90DegreesRight()
 {
     Position = Position.Spin90DegreesRight();
 }
Example #5
0
 public void Spin90DegreesLeft()
 {
     Position = Position.Spin90DegreesLeft();
 }
Example #6
0
 /* Constructor with Position parameter to allow more flexibility.
  */
 public Rover(Position position)
 {
     Position = position;
 }