Ejemplo n.º 1
0
def _calc_score(game_result):
    try:
        bowling_score = bowling.BowlingScore()
        score = bowling_score.get_score(game_result)
        print(f'Вы заработали {score} очков')
    except Exception as exc:
        print(exc)
Ejemplo n.º 2
0
 def test_no_strike_no_spare(self):
     frames = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1],
               [1, 1], [1, 1], [1, 1, 0]]
     self.assertEqual(20, bowling.BowlingScore(frames))
Ejemplo n.º 3
0
 def test_to_many_frames(self):
     with pytest.raises(Exception):
         frames = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1],
                   [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]
         assert bowling.BowlingScore(frames)
Ejemplo n.º 4
0
 def test_last_frame_required_to_be_size_three(self):
     with pytest.raises(Exception):
         frames = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1],
                   [1, 1], [1, 1], [1, 1]]
         assert bowling.BowlingScore(frames)
Ejemplo n.º 5
0
 def test_perfrect_game(self):
     frames = [[10, 0], [10, 0], [10, 0], [10, 0], [10, 0], [10, 0],
               [10, 0], [10, 0], [10, 0], [10, 10, 10]]
     self.assertEqual(300, bowling.BowlingScore(frames))
Ejemplo n.º 6
0
 def test_three_frame_second_to_last(self):
     with pytest.raises(Exception):
         frames = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1],
                   [1, 1], [1, 1, 1], [1, 1]]
         assert bowling.BowlingScore(frames)
Ejemplo n.º 7
0
 def test_alternate_strike_spare(self):
     frames = [[10, 0], [9, 1], [10, 0], [9, 1], [10, 0], [9, 1], [10, 0],
               [9, 1], [10, 0], [9, 0, 0]]
     self.assertEqual(4 * 20 + 19 + 4 * 20 + 9,
                      bowling.BowlingScore(frames))
Ejemplo n.º 8
0
 def test_all_strike(self):
     frames = [[10, 0], [10, 0], [10, 0], [10, 0], [10, 0], [10, 0],
               [10, 0], [10, 0], [10, 0], [9, 0, 0]]
     self.assertEqual(7 * 30 + 29 + 19 + 9, bowling.BowlingScore(frames))
Ejemplo n.º 9
0
 def test_all_spare(self):
     frames = [[9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1],
               [9, 1], [9, 1], [9, 1, 5]]
     self.assertEqual(9 * 19 + 15, bowling.BowlingScore(frames))
Ejemplo n.º 10
0
 def test_all_spare_first_nine(self):
     frames = [[9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1],
               [9, 1], [9, 1], [9, 0, 0]]
     self.assertEqual(9 * 19 + 9, bowling.BowlingScore(frames))