Question
CS 250 Program 07 Due: Wednesday, November 8th Main topics: User validated input if & if - else Statements Loop Statements Library Methods Program Specification:
CS 250 Program 07
Due: Wednesday, November 8th
Main topics: User validated input if & if - else Statements
Loop Statements Library Methods
Program Specification:
Write a program that allows a single Player (the user) to play a simple three dice game of chance against a single Opponent (the computer).
Game Description:
There is a single Player (human), with three dice.
There is a single Opponent (computer), with three dice.
Each die is 4 sided, and each of its sides is labeled with a unique number: 2, 3, 5 or 7.
When a die is rolled it stops with one of its sides facing down, we will call this the value of the die roll.
A game is made up of rounds, a single round is played as such:
The computer Opponent rolls its dice
The dice are displayed
The Player rolls their dice
The dice are displayed
A determination is made as to who won the round, this determination is made via the following rules:
A Triple is when all the dice have the same number on their top faces, the value of the Triple is this common value.
A Pair is when exactly two of the dice have the same number on their top faces, the value of the pair is this common value.
A Straight is when the three dice values can be arranged into a consecutive sequence, there are exactly two possible Straights 2 3 5 in any order and 3 5 7 in any order.
Junk is anything that is not a Triple, a Pair or a Straight.
Larger values beat smaller values, same values are a tie.
Any Triple beats any Straight.
Any Triple beats any Pair.
Any Triple beats any Junk.
Two Triples are compared by their respective Triple values.
Any Straight beats any Pair.
Any Straight beats any Junk.
Any 3 5 7 Straight beats any 2 3 5 Straight.
Any Pair beats any Junk.
Two Pairs are first compared by their respective Pair values, and then by their respective
non-common die values.
6. The result of the round (with respect to the Player) is announced.
7. The result of the round (with respect to the Player) is tallied, by increasing the number of player wins, ties, or loses by one.
The player is asked if they wish to play another round. When the game is over, the results of the game are announced: how many rounds the player played;
how many they won; how many they tied; how many they lost.
Notes: All user input must be validated (user validation loop) in a reasonable manner. Grading:
Sample run(s):
Welcome to opponent Dice ---------------------------------------------------------
You will be playing dice against the opponent
High beats low, and same ties Triples beat Straights, Pairs and Junk Straights beat Pairs and Junk Pairs beat Junk In the case of two identical Pairs - high card decides in the case of two Nothings - its a tie ---------------------------------------------------------
Player ------------
775
opponent ------------
333
Sorry, you lose! Do you wish to play again [y, n] : y
Player ------------
325
opponent ------------
227 Congrats, you win! Do you wish to play again [y, n] : y
Player ------------
553
opponent ------------
275 Congrats, you win! Do you wish to play again [y, n] : y
Player ------------
727
opponent ------------
272 Congrats, you win! Do you wish to play again [y, n] : y
Player ------------
577
opponent ------------
537 Sorry, you lose! Do you wish to play again [y, n] : y
Player ------------
322
opponent ------------
323 Sorry, you lose! Do you wish to play again [y, n] : y
Player ------------
723
opponent ------------
222 Sorry, you lose! Do you wish to play again [y, n] : n
opponent Dice Results --------------------- You played 7 rounds
Rounds won :3 Rounds tied :0 Rounds lost :4 ---------------------
Step 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