CIS 554 Scala 1: Twenty-One Card Game
Fall 2013, David Matuszek
To get you started programming in Scala.
This is a simplified version of a common card game, "21". Blackjack is a better-known variant.
In this version of the game, there are three players and a dealer. The dealer deals two "cards" to each player, one hidden, so that only the player knows what it is, and one face up, so that everyone can see it.
The players then take turns requesting cards, trying to get as close to 21 as possible, but not going over 21. A player may pass (ask for no more cards). Once a player has passed, he or she cannot later ask for another card. When all three players have passed, the round ends.
The winner of the round is the player who has come closest to 21 without exceeding it. In the case of a tie, or if everyone goes over 21, no one wins.
Strongly recommended: Download and install the Scala IDE bundle.
Create a project named
TwentyOne, and within that a package named
game. Create an object named
Game containing a
main method, an object
Dealer, and a class
Print out what the program is doing as it goes along. An example output might look like this:
Manny takes 5 (hidden) Moe takes 2 (hidden) Jack takes 9 (hidden) Manny takes 3 Moe takes 8 Jack takes 10 Manny takes 3 Moe takes 10 Jack passes. Manny takes 8 Moe passes. Manny passes. Moe wins with 20! Manny has 19, Moe has 20, Jack has 19.
As defined, you aren't playing the game, you are just watching it. Add yourself as a player.
Please turn in to Canvas your zip file by Friday, November 9 , before 6:00am.