Esempio n. 1
0
def main():
    print("The Dice Roller program")
    for i in range(1, 7):
        die = Die()
        die.value = i
        print(die.image)
    print()

    # get number of dice from user
    count = int(input("Enter the number of dice to roll: "))

    # create Die objects and add to Dice object
    dice = Dice()
    for i in range(count):
        die = Die()
        dice.addDie(die)

    while True:
        # roll the dice
        dice.rollAll()
        print("YOUR ROLL: ")
        for die in dice.list:
            print(die.image)
        print()
        print("TOTAL:", dice.getTotal())
        print()

        choice = input("Roll again? (y/n): ")
        if choice != "y":
            print("Bye!")
            break
Esempio n. 2
0
def main():
    print("The Dice Roller program")
    print()

    # get number of dice from user
    count = int(input("Enter the number of dice to roll: "))

    # create Die objects and add to Dice object
    dice = Dice()
    for i in range(count):
        die = Die()
        dice.addDie(die)

    while True:
        # roll the dice
        dice.rollAll()
        print("YOUR ROLL: ", end="")
        for die in dice.getTuple():
            print(die.getValue(), end=" ")
        print("\n")

        choice = input("Roll again? (y/n): ")
        if choice != "y":
            print("Bye!")
            break
Esempio n. 3
0
def main():
    print("The Dice Roller Program")
    print()

    # get number of dice from user
    count = int(input("Enter the number of dice to roll: "))

    # Dice object and add Die objects to it
    dice = Dice()
    for i in range(count):
        die = Die()
        dice.addDie(die)

    while True:
        # roll the dice
        dice.rollAll()
        print("Your Roll: ", end="")
        for die in dice.list:
            print(die.value, end=" ")
        print("\n")

        choice = input("Roll again? (y/n): ")
        if choice != "y":
            print("Bye!")
            break
Esempio n. 4
0
def main():
    print("The Dice Roller program")
    print()

    # get the number of dice from user
    count = int(input('Enter the number of dice to roll: '))

    # create Dice object and add Die objects to it
    dice = Dice()
    for i in range(count):
        die = Die()
        dice.addDie(die)

    while True:
        # roll the dice
        dice.rollAll()
        print("YOUR ROLL: ", end="")
        for die in dice.list:
            print(die.value, end=" ")
        print("\n")

        choice = input("Roll again? (y/n): ").lower()
        if choice != 'y':
            print("Bye!")
            break
Esempio n. 5
0
def main():
    print("The Dice Roller program")
    print(" _____ \n" + \
          "|o   o|\n" + \
          "|o   o|\n" + \
          "|o___o|")
    print(" _____ \n" + \
          "|o   o|\n" + \
          "|  o  |\n" + \
          "|o___o|")
    print(" _____ \n" + \
          "|o   o|\n" + \
          "|     |\n" + \
          "|o___o|")
    print(" _____ \n" + \
          "|o    |\n" + \
          "|  o  |\n" + \
          "|____o|")
    print(" _____ \n" + \
          "|o    |\n" + \
          "|     |\n" + \
          "|____o|")
    print(" _____ \n" + \
          "|     |\n" + \
          "|  o  |\n" + \
          "|_____|")
    print()

    # get number of dice from user
    count = int(input("Enter the number of dice to roll: "))

    # create Die objects and add to Dice object
    dice = Dice()
    for i in range(count):
        die = Die()
        dice.addDie(die)

    while True:
        # roll the dice
        dice.rollAll()
        print("YOUR ROLL: ")
        for die in dice.list:
            print(die.image)
        print("\n")

        choice = input("Roll again? (y/n): ")
        if choice != "y":
            print("Bye!")
            break
Esempio n. 6
0
def main():
    print("The Dice Roller program")
    # Declare i as 6
    i = 6
    # Use a loop to create a Die object until i equals 0
    while i != 0:
        # Create a Die object by using i as the value
        d = Die(i)
        # Call the image function to draw the die's picture
        d.image
        # Decrement i byy 1
        i -= 1
    # Print an empty line
    print()
    # get number of dice from user
    count = int(input("Enter the number of dice to roll: "))

    # create Die objects and add to Dice object
    dice = Dice()
    for i in range(count):
        die = Die(None)
        dice.addDie(die)

    while True:        
        # roll the dice
        dice.rollAll()
        print("YOUR ROLL: ")
        for die in dice.list:
            # Call the image function from Die class to draw picture of the value
            die.image
        print("\n")
        # Call the getTotal function from the Dice class and assign it to tot
        tot = dice.getTotal()
        # print tot
        print("Total: " + str(tot))
        # Call the getAvg function from the Dice class and assign it to avg
        avg = dice.getAvg()
        # print avg
        print("Average: " + str(avg) + "\n")
        choice = input("Roll again? (y/n): ")
        if choice != "y":
            print("Bye!")
            break
Esempio n. 7
0
def main():
    myTimer = timer.begin_timer()
    stringer.show_welcome(NAME)
    print()

    while True:
        print()

        try:
            number = val.get_int("Enter number of dice to roll: ", 10,
                                 0)  # use validation module to set max 10 dice

            #create Dice object to hold the dice
            dice = Dice()
            for i in range(number):
                die = Die()
                dice.addDie(die)

            #roll dem bones!
            dice.rollAll()

            print("YOUR ROLL: ")
            # use itertor from class Dice
            for die in dice:
                print(die.getImage())
            print()

        except Exception as e:
            print("There was an Error processing your roll.", e)
            break

        choice = input("Roll again? (y/n): ").lower()
        if choice != "y":
            break

    # end while loop

    timer.stop_timer(myTimer)
    print("Bye!")