public void RoverCanMoveForward(RoverState initialState, RoverState expectedState) { var rover = new Rover.Rover(_fixture.map, initialState); rover.MoveForward(); Assert.True(rover.GetCurrentState().Equals(expectedState)); }
public void RoverCanTrun(RoverState initialState, Rover.Rover.Turns turn, RoverState expectedState) { var rover = new Rover.Rover(_fixture.map, initialState); rover.Turn(turn); Assert.True(rover.GetCurrentState().Equals(expectedState)); }
static void Main(string[] args) { var plateau = new Plateau(5, 5); var dispatcher = new DefaultInstructionDispatcher(); var rover1 = new Rover("Rover 1", plateau, new Position(1, 2, Direction.N)); dispatcher.Dispatch(rover1, "LMLMLMLMM"); var rover2 = new Rover("Rover 2", plateau, new Position(3, 3, Direction.E)); dispatcher.Dispatch(rover2, "MMRMMRMRRM"); Clear(); Print(plateau); Print(rover1); Clear(); //Print(plateau); //Print(rover2); Console.WriteLine(rover1); Console.WriteLine(rover2); Console.ReadLine(); }
public void RoverCanTrackCreationOutOfBoundarysError() { var x = _fixture.map.maxX + 1; var y = _fixture.map.maxY + 1; var rover = new Rover.Rover(_fixture.map, new RoverState(x, y, Directions.South)); Assert.Equal($"({x},{y}) is out of map boundary.", rover.GetLastError()); }
static void Print(Rover rover) { foreach (var item in rover.Movements) { Console.SetCursorPosition(item.X, item.Y); Console.Write("X"); } }
public void RoverCanTrackMovingOutOfBoundaryError() { var rover = new Rover.Rover(_fixture.map, new RoverState(1, 1, Directions.South)); rover.MoveForward(); Assert.Null(rover.GetLastError()); rover.MoveForward(); Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError()); //rover should stop moving when it's next step is out of boundary rover.MoveForward(); Assert.Equal($"(1,{1 - 2}) is out of map boundary.", rover.GetLastError()); }
public void Dispatch(Rover rover, string instructions) { foreach (var instruction in instructions) { if (instruction == Move) { rover.Move(); } else if (instruction == Left) { rover.Left(); } else if (instruction == Right) { rover.Right(); } } }
public void RoverCanReturnCurrentSatus(RoverState initialState) { var rover = new Rover.Rover(_fixture.map, initialState); Assert.True(initialState.Equals(rover.GetCurrentState())); }
static void Main(string[] args) { //Console.SetIn(new System.IO.StreamReader((System.IO.File.OpenRead("...")))); uncomment for test Rover rover = new Rover(); Console.WriteLine(rover.Decide()); }
public NameRadar(string name, Environment env, Rover rover) : base(name, env, rover) { }
public MoveForwardCommand(Rover rover) : base(rover) { }
public LocationRadar(string name, Environment env, Rover rover) : base(name, env, rover) { }
public Radar(string name, Environment env, Rover rover) : base(name, USES_CHARGE, rover) { }
public RotateRightCommand(Rover rover) : base(rover) { }