public override void MoveAhead(Rover rover) { //TODO: Check collision with another Rover int yCurrent = rover.GetCurrentLocation().Y; if (++yCurrent <= rover.GetMaxLocation().Y) { rover.SetCurrentLocation(new Point(rover.GetCurrentLocation().X, yCurrent)); } else { throw new InvalidOperationException("Can't move forward, dead end ahead"); } }
public override void MoveAhead(Rover rover) { //TODO: Check collision with another Rover int xCurrent = rover.GetCurrentLocation().X; if (--xCurrent >= 0) { rover.SetCurrentLocation(new Point(xCurrent, rover.GetCurrentLocation().Y)); } else { throw new InvalidOperationException("Can't move forward, dead end ahead"); } }