Created
November 2, 2013 00:35
-
-
Save oyvindrobertsen/7274067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player(self): | |
name = "" | |
score = 0 | |
thrown = 0 | |
throws_left = 10 | |
def __init__(self, name="Anon"): | |
self.name = name | |
def throw(self): | |
# Skriv kode som simulerer et kast, altsaa kall getThrow(), endre score-medlemsvariabelen | |
# og regn ut hvor mange kast spilleren har igjen, sjekk ogsaa om spilleren har flere kast igjen | |
return | |
def getThrow(max): | |
a = input('Neste kast: ') | |
return a if a <= max else getThrow(max) | |
def printScore(score): | |
s = '' | |
print '-------------------------------------------------------------------------------' | |
for i in range (10): | |
if i == 9: | |
s += 'k, ' + str(i + 1) + '| ' | |
else: | |
s += 'k, ' + str(i + 1) + ' | ' | |
s += ' Total' | |
print s | |
s = '' | |
for i in score: | |
if len(i) == 1 and i[0] != None: | |
if i[0] == 10: | |
s += ' X | ' | |
else: | |
s += str(i)[1:-1] + ', * | ' | |
elif len(i) == 2 and i[0] + i[1] == 10: | |
s += str(i[0]) + ', / | ' | |
elif str(i[0]) == 'None': | |
#s += str(i)[1:-1] + ' | ' | |
s += '*, * | ' | |
else: | |
s += str(i)[1:-1] + ' | ' | |
print s | |
print '-------------------------------------------------------------------------------' | |
def main(): | |
players = [Player(input('Navn paa spiller ', i, ': ')) for i in range(10)] | |
max = 10 | |
while True: | |
for player in players: | |
player.throw() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment