Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The rules are as follows. The shooter rolls two dice. If the first roll is 2, 3, or 12 the shooter loses. If the

imageimageimage

The rules are as follows. The shooter rolls two dice. If the first roll is 2, 3, or 12 the shooter loses. If the first roll is 7 or 11, the shooter wins. If the first roll is anything else, that value becomes the shooter's "point". The shooter continues to roll the dice until either the "point" comes up again, in which case the shooter wins, or until a 7 comes up, in which case the shooter loses. The program, will be created using 4 files: A module called die.py which defines the Die class representing a single die. The die should have a succent value attribute that represents its current face-up value (i.e. the last value it was rolled). The die should also have a method called ro11() that sets its current value to a random integer between 1 and 6. A module called pair_of_dice.py which defines the class Paicoffice which has two Die class attributes. It should have a call.diss) method and a succent value() method that returns the sum of its Die objects' current values. A module called game_controller.py, which defines the SansController class to manage the rolling, scoring, and user interaction. This will be the file that contains the most code. A main application called dice_game.py, with a main() method that prints out the rules and then calls a method on the game controller to initiate the game. Running the game A few examples of the game in action are shown below: $ python dice_game.py Welcome to street craps! Rules: If you roll 7 or 11 on your first roll, you win. If you roll 2, 3, or 12 on your first role, you lose. If you roll anything else, that's your 'point', and you keep rolling until you either roll your point again (win) or roll a 7 (lose) Press enter to roll the dice... Your point is 4 Press enter to roll the dice... You rolled 7. You lose. $ python dice game.py Welcome to street craps! Rules: If you roll 7 or 11 on your first roll, you win. If you roll 2, 3, or 12 on your first role, you lose. If you roll anything else, that's your 'point', and you keep rolling until you either roll your point again (win) or roll a 7 (lose) Press enter to roll the dice... You rolled 11. You win! $ python dice_game.py Welcome to street craps! Rules: If you roll 7 or 11 on your first roll, you win. If you roll 2, 3, or 12 on your first role, you lose. If you roll anything else, that's your 'point', and you keep rolling until you either roll your point again (win) or roll a 7 (lose) Press enter to roll the dice... Your point is 8 Press enter to roll the dice.... You rolled 4. Press enter to roll the dice... You rolled 7. You lose. $ python dice_game.py Welcome to street craps! Rules: If you roll 7 or 11 on your first roll, you win. If you roll 2, 3, or 12 on your first role, you lose. If you roll anything else, that's your "point", and you keep rolling until you either roll your point again (win) or roll a 7 (lose) Press enter to roll the dice... Your point is 10 Press enter to roll the dice.... You rolled 8. Press enter to roll the dice.... You rolled 4. Press enter to roll the dice... You rolled 10. You win!

Step by Step Solution

3.34 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

ANSWER First lets define the Die class in diepy import random class Die def initself selfvalue None def rollself selfvalue randomrandint1 6 This class represents a single die It has a value attribute ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability And Statistics

Authors: Morris H. DeGroot, Mark J. Schervish

4th Edition

9579701075, 321500466, 978-0176861117, 176861114, 978-0134995472, 978-0321500465

More Books

Students also viewed these Programming questions