예제 #1
0
def test_ship_forward():
    ship = Ship(Position(0, 0))
    ship.forward(10)
    assert ship.position == Position(10, 0)
    ship.rotate("R", 180)
    assert ship.position == Position(10, 0)
    ship.forward(10)
    assert ship.position == Position(0, 0)
    ship.forward(30)
    assert ship.position == Position(-30, 0)
예제 #2
0
def test_ship_rotation_left():
    ship = Ship(Position(0, 0))
    ship.rotate("L", 90)
    assert ship.degrees == 90
    ship.rotate("L", 90)
    assert ship.degrees == 180
    ship.rotate("L", 90)
    assert ship.degrees == 270
    ship.rotate("L", 90)
    assert ship.degrees == 0
    ship.rotate("L", 180)
    assert ship.degrees == 180
예제 #3
0
def test_ship_rotation_right():
    ship = Ship(Position(0, 0))
    ship.rotate("R", 90)
    assert ship.degrees == 270
    ship.rotate("R", 90)
    assert ship.degrees == 180
    ship.rotate("R", 90)
    assert ship.degrees == 90
    ship.rotate("R", 270)
    assert ship.degrees == 180