Skip to content

Instantly share code, notes, and snippets.


explorer14/RoverInit.cs Secret

Created Jun 22, 2020
What would you like to do?
public sealed class Rover
private readonly Terrain terrain;
public Rover(
Terrain terrain,
int startingPositionX,
int startingPositionY,
Direction startingHeading)
if (terrain == null)
throw new ArgumentNullException(
"Rover cannot navigate on a non-existent terrain!");
if (IsStartingPositionOutsideTerrain(
throw new ArgumentOutOfRangeException(
"Rover cannot start outside the terrain");
if (!Enum.IsDefined(typeof(Direction), startingHeading))
throw new ArgumentOutOfRangeException(
"Starting heading is invalid, must be one of NORTH, EAST, WEST or SOUTH");
this.terrain = terrain;
StartingPositionX = startingPositionX;
StartingPositionY = startingPositionY;
NewPositionX = StartingPositionX;
NewPositionY = StartingPositionY;
StartingHeading = startingHeading;
NewHeading = StartingHeading;
Id = Guid.NewGuid();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.