Beispiel #1
0
        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 }
            };
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 protected bool Equals(Plateau other)
 {
     return(MaxSizeX == other.MaxSizeX && MaxSizeY == other.MaxSizeY);
 }
Beispiel #4
0
 public static Plateau SetPlateu(Size size)
 {
     _plateau = new Plateau(size.Width, size.Height);
     return(_plateau);
 }
Beispiel #5
0
 public Rover(Plateau plateau, Point coordinate, Direction direction)
 {
     this.Plateau    = plateau;
     this.Coordinate = coordinate;
     this.Direction  = direction;
 }
Beispiel #6
0
 /// <summary>
 /// Returns is rover in coordinates of plateau
 /// </summary>
 /// <returns>Is rover in coordinates of plateau</returns>
 public bool IsInsidePlateau()
 {
     return(Plateau.IsInsidePlateau(Position));
 }