public DroneModel turnRight(DroneModel drone) { var currentDirection = drone.GetDirection(); // Turn right and set updated direction switch (currentDirection) { case CardinalDirections.North: drone.SetDirection(CardinalDirections.East); break; case CardinalDirections.East: drone.SetDirection(CardinalDirections.South); break; case CardinalDirections.South: drone.SetDirection(CardinalDirections.West); break; case CardinalDirections.West: drone.SetDirection(CardinalDirections.North); break; } return(drone); }
public DroneModel moveForward(DroneModel drone) { var currentDirection = drone.GetDirection(); switch (currentDirection) { case CardinalDirections.North: if (GridModel.yBoundary - drone.yCord > 0) { drone.yCord++; } break; case CardinalDirections.East: if (GridModel.xBoundary - drone.xCord > 0) { drone.xCord++; } break; case CardinalDirections.South: if (drone.yCord > 0) { drone.yCord--; } break; case CardinalDirections.West: if (drone.xCord > 0) { drone.xCord--; } break; } return(drone); }