



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Files to submit: hw11.py
1. Fill in skeleton code provided
IMPORTANT NOTES:
A good source of information for completing this homework would be to look in your old completed homework or in the book.
http://en.wikipedia.org/wiki/Yahtzee
In this assignment, you will be programming a small part of the popular dice game, Yahtzee.
In the game, players roll 5 dice and make poker-like combinations out of them in order to rack up certain point values.
Specifically, we will be making a YahtzeeHand class which contains an array of 5 numbers and 3 different methods which check to see if you have rolled certain hands.
While there are many more combination of dice, you only need to check for these 3:
In this method, you need to take in 5 integer values between 1 and 6 inclusive. You may assume you will always have valid input and you do not need to check.
This is a simple method that returns a string representation of the YatzheeHand object. It should be a 5 digit number with no spaces.
Don’t overthink this method – it should only be 1-2 lines. Hint: Remember to use str as needed on the dice array to get strings.
Return true if all of the dice have the same value; else return false.
Return true if we have all 5 dice in a row; else return false. Hint: remember, since we sorted the dice, the only 2 possible combinations are : 1,2,3,4,5 OR 2,3,4,5,
Return true if we have AT least 4 dice that are all the same (ie. All Yatzhees are automatically 4 of a kinds); else returns false.
Hint: remember that the dice are all sorted, so the 4 dice that are the same would need to be contiguous.
Here is output with debug mode off: If you are not getting the correct answers, try turning debug mode on and looking at each row of data to see where you are miscounting.
================================ RESTART ================================
Please enter seed: 8 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 1 Straights: 30 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 19 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 5 Straights: 25 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 28 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 2 Straights: 27 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 991 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 0 Straights: 41 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 677 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 1 Straights: 29 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 314 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 1 Straights: 43 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 574 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 1 Straights: 35 Four of a Kinds:
================================ RESTART ================================
Please enter seed: 271 Enter 1 for debug mode, 0 for no extra output: Yahtzees: 3 Straights: 25 Four of a Kinds:
Once again, please be sure your program works perfectly before turning it in. Since it is due during dead week, we are trying to get it graded extremely quickly and it is much easier for us to give you full credit than to find out what you did wrong.
Good Luck!
Written by Joshua Silver, Fall 2006