Exemplo n.º 1
0
def main():
    ## Play a game of dice.
    dice1 = pairOfDice.PairOfDice()
    dice1.roll()
    print("Player 1:", dice1.sum())
    dice2 = pairOfDice.PairOfDice()
    dice2.roll()
    print("Player 2:", dice2.sum())
    if dice1.sum() == dice2.sum():
        print("TIE")
    elif dice1.sum() > dice2.sum():
        print("Player 1 wins.")
    else:
        print("Player 2 wins.")
Exemplo n.º 2
0
def main():
    p1 = pairOfDice.PairOfDice()
    p2 = pairOfDice.PairOfDice()
    p1.roll()
    p2.roll()
    p1Sum = p1.sum()
    p2Sum = p2.sum()
    print("Player 1: ",p1Sum)
    print("Player 2: ",p2Sum)
    if p1Sum > p2Sum:
        print("Player 1 wins.")
    elif p1Sum == p2Sum:
        print("Tie.")
    else:
        print("Player 2 wins.")
Exemplo n.º 3
0
def main():
    ## Roll a pair of dice.
    dice = pairOfDice.PairOfDice()
    dice.roll()
    print("Red die:", dice.getRedDie())
    print("Blue die:", dice.getBlueDie())
    print("Sum of the dice:", dice.sum())
Exemplo n.º 4
0
def playGame():
    doubleSixes = False
    dice = pairOfDice.PairOfDice()
    for i in range(24):
        dice.roll()
        if dice.sum() == 12:
            doubleSixes = True
    return doubleSixes
Exemplo n.º 5
0
def main():
    numberOfSevens = 0
    for i in range(100000):
        dice = pairOfDice.PairOfDice()
        dice.roll()
        if dice.sum() == 7:
            numberOfSevens += 1
    print("7 occurred {0:.2%} of the time.".format(numberOfSevens / 100000))
Exemplo n.º 6
0
def main():
    dice = pairOfDice.PairOfDice()
    count = 0
    for i in range(10000):
        dice.roll()
        if dice.sum() == 7:
            count += 1
    print("{0:.2%}".format(count / 10000))
Exemplo n.º 7
0
def main():
    a = di.PairOfDice()
    a.roll()
    aRedDie = a.getRedDie()
    aBlueDie = a.getBlueDie()
    sum = a.sum()
    print("Red die:", aRedDie)
    print("Blue die:", aBlueDie)
    print("Total:", sum)
Exemplo n.º 8
0
def main():
    dice = pairOfDice.PairOfDice()
    count10k = 0
    for i in range(10000):
        count24 = 0
        for j in range(24):
            dice.roll()
            if (dice.sum() == 12):
                count24 += 1
        if count24 > 0:
            count10k += 1
    print("{0:.2%}".format(count10k / 10000))
Exemplo n.º 9
0
def main():
    dice=pairOfDice.PairOfDice()
    dice.roll()
    print("Red die: ", dice.getRedDie())
    print("Blue die: ", dice.getBlueDie())
    print("Total: ", dice.sum())