def test_turn_right(self): ship = Ship(17, 3, 0) ship.turn_right(90) ship.go_forward(11) self.assertEqual(ship.x, 17) self.assertEqual(ship.y, -8) self.assertEqual(ship.compute_distance(), 25)
def test_part1(self): input = ["F10", "N3", "F7", "R90", "F11"] ship = Ship() ship.print() ship.navigate(input) self.assertEqual(ship.x, 17) self.assertEqual(ship.y, -8) self.assertEqual(ship.compute_distance(), 25)
def test_part2(self): input = ["F10", "N3", "F7", "R90", "F11"] ship = Ship() ship.turnon_waypoint(10, 1) ship.print() ship.navigate(input) self.assertEqual(ship.x, 214) self.assertEqual(ship.y, -72) self.assertEqual(ship.compute_distance(), 286)
def test_rotate_waypoint(self): ship = Ship(170, 38) ship.turnon_waypoint(10, 4) ship.turn_right(90) self.assertEqual(ship.x, 170) self.assertEqual(ship.y, 38) self.assertEqual(ship.wp_x, 4) self.assertEqual(ship.wp_y, -10) ship.go_forward(11) self.assertEqual(ship.x, 214) self.assertEqual(ship.y, -72) self.assertEqual(ship.compute_distance(), 286)