ש Shin ה Hey ג Gimmel נ Nun
The game has multiple players each of whom is given the same number of tokens. Players all place one token in to a “pot” and spin the dreidel to see who goes first. The player who spins the highest value starts. Note: nun is highest, then gimmel, hey, and shin. If there is a tie, the players who tied spin again.
Each player takes turn spinning the dreidel and taking an action depending on what letter they spin.
* Shin: put one more token in the pot
* Nun: do nothing
* Gimmel: take all tokens from the pot
* Hay: take half of all tokens lying in the pot.In case of an odd number of tokens, round up.
The game ends when one player has all the tokens or after some set period of time or mutual agreement.
There are lots of ways to program this of course. Normally, at this point in the semester I have been teaching students how to create simple classes. So when I wrote my solution I created a dreidel class. There are some reasons that this makes for a nice class to create. There is the usual protected data – the face value of the dreidel. And there is the obvious spin and get value methods. I also over loaded the ToString and CompareTo methods.
The ToString method allows for displaying the name of the face value of the dreidel. CompareTo is particularly useful for selecting the high spin at the beginning of the game.
I also added some public const values for the face values so that I could use them in calling programs without the programmer needing to know what the actual values are.
if (player.Value== Dreidel.Shin)
Here we have a fairly simple game to program with a class that lets the programmer do some interesting overloads and activities without too much complexity.
Inspired by a project idea posted on the AP CS Teachers Facebook group group (https://www.facebook.com/groups/APComputerSciencePrinciples/permalink/1873272652824371/) Thanks to Lee Whiteley for sharing with the community..
No comments:
Post a Comment