class BowlingGame: def __init__(self): self.score = BowlingScore() def launch(self): for i in range(10): print('Round ', i, ': Enter your score') self.request_score() print('> Total score', self.score.sum()) def request_score(self): score_val1 = int(input('first shot :')) while not check_input(score_val1): score_val1 = int(input('Wrong value, Enter your score:')) score_val2 = 0 if not score_val1 == 10: score_val2 = int(input('second shot :')) while (not check_input(score_val2)) or score_val1 + score_val2 > 10: score_val2 = int(input('Wrong value, re-enter second shot:')) self.score.add(score_val1, score_val2) print('Current score : ', self.score.sum())
def test_sum_one_couple_strike(self): cp = BowlingScore() cp.add(10, 0) self.assertEqual(10, cp.sum())
def test_sum_tuples_empty(self): # liste vide cp = BowlingScore() self.assertEqual(0, cp.sum())
def test_sum_with_second_number_ten(self): cp = BowlingScore() cp.add(0, 10) cp.add(6, 3) self.assertEqual(25, cp.sum())
def test_sum_with_first_number_ten(self): cp = BowlingScore() cp.add(10, 0) cp.add(6, 3) self.assertEqual(28, cp.sum())
def test_sum_with_couple_equal_ten(self): cp = BowlingScore() cp.add(5, 5) cp.add(6, 3) self.assertEqual(25, cp.sum())
def test_sum_tuples_multiple_tuples(self): cp = BowlingScore() cp.add(3, 5) cp.add(6, 2) self.assertEqual(16, cp.sum())
def test_sum_tuples_one_couple(self): cp = BowlingScore() cp.add(1, 2) self.assertEqual(3, cp.sum())