public Rover(Plateau plateau) { Plateau = plateau; // Being on the edge may have different meanings depending on the direction EdgeFunctions = new Dictionary <DirectionE, Func <bool> > { { DirectionE.N, () => PositionY == Plateau.MaxY }, { DirectionE.W, () => PositionX == 0 }, { DirectionE.S, () => PositionY == 0 }, { DirectionE.E, () => PositionX == Plateau.MaxX } }; }
public void DropRover(int roverX, int roverY, string letter, char[] commands) { Plateau newPlateau = new Plateau(x, y); Position newPosition = new Position(roverX, roverY); Orientation newOrientation = new Orientation(letter); Rover newRover = new Rover(newPosition, newOrientation, commands); if (newPosition.x > x || newPosition.y > y) { throw new System.InvalidOperationException("Can Not Place Rover Here"); } _rovers.Add(newRover); }
protected bool Equals(Plateau other) { return(MaxSizeX == other.MaxSizeX && MaxSizeY == other.MaxSizeY); }
public static Plateau SetPlateu(Size size) { _plateau = new Plateau(size.Width, size.Height); return(_plateau); }
public Rover(Plateau plateau, Point coordinate, Direction direction) { this.Plateau = plateau; this.Coordinate = coordinate; this.Direction = direction; }
/// <summary> /// Returns is rover in coordinates of plateau /// </summary> /// <returns>Is rover in coordinates of plateau</returns> public bool IsInsidePlateau() { return(Plateau.IsInsidePlateau(Position)); }