def test_move_east_out_from_land(self): probe = Probe(0,0,"E") land = Land(0,0) nasa = Nasa(land) self.assertWarns(UserWarning, nasa.move, probe, "M") movedProbe = nasa.move(probe, "M") self.assertEqual(movedProbe, probe)
import logging from model.probe import Probe from model.land import Land from controller.nasa import Nasa def main(land, probe, movements): nasa = Nasa(land) for direction in movements: probe = nasa.move(probe, direction) return "{} {} {}".format(probe.x, probe.y, probe.direction) if __name__ == "__main__": landInput = input() indexes = landInput.split(" ") land = Land(int(indexes[0]), int(indexes[1])) try: while True: probeLocation = input() location = probeLocation.split(" ") probe = Probe(int(location[0]), int(location[1]), location[2]) movements = input() print(main(land, probe, movements)) except EOFError: logging.info("End of program")
def test_move_left_when_facing_north(self): probe = Probe(0,0,"N") land = Land(0,0) nasa = Nasa(land) self.assertEqual(nasa.move(probe, "L").direction, "W")
def test_move_right_when_facing_east(self): probe = Probe(0,0,"E") land = Land(0,0) nasa = Nasa(land) self.assertEqual(nasa.move(probe, "R").direction, "S")
def test_first_input(self): land = Land(5, 5) probe = Probe(1, 2, "N") result = main(land, probe, "LMLMLMLMM") self.assertEqual(result, "1 3 N")
def test_circling(self): land = Land(5, 5) probe = Probe(3, 3, "E") result = main(land, probe, "LLLL") self.assertEqual(result, "3 3 E")
def test_out_of_mars(self): land = Land(5, 5) probe = Probe(3, 3, "E") result = main(land, probe, "MMRMMRMRRMMMMMMMM") self.assertEqual(result, "5 1 E")
def test_second_input(self): land = Land(5, 5) probe = Probe(3, 3, "E") result = main(land, probe, "MMRMMRMRRM") self.assertEqual(result, "5 1 E")