Question
Dices ver0.1 (dices_0_1.py) is a 2-dice double-or-nothing-dice-game User inputs bet that is between 1 - pot. Pot is 100 in the beginning (entry fee
""" Dices ver0.1 (dices_0_1.py) is a 2-dice double-or-nothing-dice-game
User inputs bet that is between 1 - pot. Pot is 100 in the beginning (entry fee to the game). Dices are rolled, the result checked, win or lose is calculated, and and added to or removed from the pot. The result, pot, and faces are displayed. If the pot is bigger than 0 the game continues and user can enter new bet.
The game ends when the pot is gone. User can not be in dept (pot is always bigger or equal to 0) and if user ends game before the pot is gone the pot is not saved (user can cash it) to next game (casino can not be in dept).
Quiz 6 and Lab 6 """ import random
class Dices: ''' encapsulates attributes commonly used in dice games (pot and bet) and functions roll and check. Checking is done according to the rules of each game. ''' def __init__(self, number = 2, pot = 100, bet = 1 ) : ''' defines and initializes attributes ''' self.pot = pot self.bet = bet self.number = number @property def pot(self): return self.__pot @pot.setter def pot(self, pot): ''' forces pot to be >= 0 ''' self.__pot = pot if self.__pot = 1 and bet
while True : bet = input('Place your bet or ENTER to exit: ').strip() if len(bet) >= 1 : try : dices.bet = int(bet) dices.roll() print(dices.check()) if dices.pot 0: print(f'Your gross winnings {dices.pot} can be chashed-out at cashier\'s desk.') break if __name__ == '__main__' : main()
Write a new version of Dices (dices_1_0.py) that is a tkinter program i.e. Dices inherit Tk class from tkinter. The returned file dices_1_0.py) contains one class Dices, that inherits Tk and the program is started from script if _name__ =='_main_: root = Dices root.mainloopo You can use as a starting point either your own Dices game class (Lab 6) or model answer dices_0_1.py Separate the creation of layout to createLayout-method and when the pot is gone show messagebox that informs user that the game is over and if user wants to play again, another 100 playmarks need to purchased for the initial pot. If the user agrees the game starts from the beginning. Do you want to play again? To start a new game you have to deposit 100 for the new pot Game over message The appearance and widgets to implement it are free of choice, but user has to be able to set bet before each toss, see the result of each toss (the faces) and updated pot. The posterior Boles Banda Youporn 5. You You Example of starting the program, setting bet to 1, rolling and losing setting the bet to 98 and losing the pot. The Dices class has to have the attributes l_pot, _bet, _number, and _faces) and properties (pot, bet, and number) from version 0.1 as well as methods roll and check. In addition to attributes and methods, at least createLayout, required to implement the graphical user interface of the program. Write a new version of Dices (dices_1_0.py) that is a tkinter program i.e. Dices inherit Tk class from tkinter. The returned file dices_1_0.py) contains one class Dices, that inherits Tk and the program is started from script if _name__ =='_main_: root = Dices root.mainloopo You can use as a starting point either your own Dices game class (Lab 6) or model answer dices_0_1.py Separate the creation of layout to createLayout-method and when the pot is gone show messagebox that informs user that the game is over and if user wants to play again, another 100 playmarks need to purchased for the initial pot. If the user agrees the game starts from the beginning. Do you want to play again? To start a new game you have to deposit 100 for the new pot Game over message The appearance and widgets to implement it are free of choice, but user has to be able to set bet before each toss, see the result of each toss (the faces) and updated pot. The posterior Boles Banda Youporn 5. You You Example of starting the program, setting bet to 1, rolling and losing setting the bet to 98 and losing the pot. The Dices class has to have the attributes l_pot, _bet, _number, and _faces) and properties (pot, bet, and number) from version 0.1 as well as methods roll and check. In addition to attributes and methods, at least createLayout, required to implement the graphical user interface of the programStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started