コード例 #1
0
def d110MetreHurdles(players):
    print_description('110 Metre Hurdles')
    for player in players:
        score = input('Score for {}: '.format(player.name))
        while not decathlon.validateInput(score, 30, minimum=5):
            score = input('Please enter a valid number between 5-30: ')
        score = int(score)
        player.scores['110 Metre Hurdles'] = score
    os.system('clear')
コード例 #2
0
def d400Metres(players):
    print_description('400 Metres')
    for player in players:
        score = input('Score for {}: '.format(player.name))
        while not decathlon.validateInput(score, 40, minimum=0):
            score = input('Please enter a valid number from 0 - 40: ')
        score = int(score)
        player.scores['400 Metres'] = score
    os.system('clear')
コード例 #3
0
def dLongJump(players):
    print_description('Long Jump')
    for player in players:
        print('\n{} attempts'.format(player.name))
        best_score = 0
        for attempt in range(1, 4):
            score = input('Attempt {}: '.format(attempt))
            while not decathlon.validateInput(score, 30):
                score = input('Please enter a number from 0-30: ')
            score = int(score)
            best_score = max(best_score, score)
        player.scores['Long Jump'] = best_score
        print()
    os.system('clear')
コード例 #4
0
def one_attempt(players, discipline, min_score, max_score):
    '''Players get one attempt at the discipline. Possible scores are
    min_score <= score <= max_score'''

    print_description(discipline)

    for player in players:
        score = input('Score for {}: '.format(player.name))
        score = decathlon.validateInput(score,
                                        minimum=min_score,
                                        maximum=max_score)
        player.scores[discipline] = score
    os.system('clear')

    updateTotals(players)
コード例 #5
0
def dShotPut(players):
    print_description('Shot Put')
    for player in players:
        print('\n{} attempts'.format(player.name))
        best_score = 0
        for attempt in range(1, 4):
            score = input('Attempt {}: '.format(attempt))
            while not decathlon.validateInput(
                    score, 40, minimum=8, invalid=True):
                score = input('Please enter a valid number from 0-40: ')
            score = int(score)
            best_score = max(best_score, score)
        player.scores['Shot Put'] = best_score
        print()
    os.system('clear')
コード例 #6
0
def dDiscus(players):
    print_description('Discus')
    for player in players:
        print('\n{} attempts'.format(player.name))
        best_score = 0
        for attempt in range(1, 4):
            score = input('Attempt {}: '.format(attempt))
            while not decathlon.validateInput(
                    score, 30, minimum=10, invalid=True):
                score = input('Please enter a valid number between 10-30: ')
            score = int(score)
            best_score = max(best_score, score)
        player.scores['Discus'] = best_score
        print()
    os.system('clear')
コード例 #7
0
def three_attempts(players, discipline, min_score, max_score):
    '''Players have three attempts to get the highest score possible.
    Scores range from min_score <= score <= max_score'''

    print_description(discipline)

    for player in players:
        print('\n{} attempts'.format(player.name))
        best_score = 0

        for attempt in range(1, 4):
            score = input('Attempt {}: '.format(attempt))
            score = decathlon.validateInput(score, minimum=min_score,
                                            maximum=max_score, invalid=True)
            best_score = max(best_score, score)
        player.scores[discipline] = best_score

        print()
    os.system('clear')

    updateTotals(players)