Example #1
0
 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)
Example #2
0
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")
Example #3
0
 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")
Example #4
0
 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")
Example #5
0
 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")
Example #6
0
 def test_circling(self):
     land = Land(5, 5)
     probe = Probe(3, 3, "E")
     result = main(land, probe, "LLLL")
     self.assertEqual(result, "3 3 E")
Example #7
0
 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")
Example #8
0
 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")