This large, end of semester project will be due on Tuesday, December 5th at 11:59pm. We will be working on this in class until we begin review for the final exam but you will also need to put in quite a bit of time at home as well. I recommend at least 30 minutes per night.
This is the final lab for this semester and is meant to sum up everything you have learned. Please make a folder containing all of your source code (.java files) for this project and put this folder in your google drive folder. It is probably easiest to just copy over and submit your entire BlueJ project folder. When I run your program, I will test your game by running the Casino.java file (so put a main method in it) and playing it. Your program will include and use other .java files as well.
***WORK ON THIS OUTSIDE OF CLASS. THERE IS AN ENORMOUS CORRELATION BETWEEN PEOPLE WHO STAY ON TRACK AND PUT IN WORK AT HOME AND PEOPLE WHO GET GOOD GRADES ON THIS PROJECT. LAST YEAR, MANY PEOPLE PROCRASTINATED UNTIL THE LAST COUPLE DAYS AND GOT DESTROYED. DO NOT PROCRASTINATE ON THIS ASSIGNMENT***
Here are some graphs from recent years comparing each student's score on this assignment versus how many hours early the project was submitted:
Description:
In this project, you will be implementing a casino application which will be run through Casino.java. In your casino, the player should start with 100 dollars and be able to play blackjack and poker (we will be playing video poker that is just one person and has a defined bet structure). The player should be able to switch freely between games, keeping an amount of money that is changing with each round. When a player switches to a new game, the deck should reshuffle and start over. Make sure that your game is easy for the user to play and it is intuitive for them to choose options inside your program.
Blackjack:
The point of blackjack is to get a score as close to 21 as possible without going over. You will receive two face up cards, the computer (dealer) receives one card face down (which you cannot see as you bet) and one card face up (which you can). You may keep your hand (stay) or add another card from the top of the deck (hit) as long as you do not bust (go over 21). You may hit multiple times if you are still under 21 and you may stay at any point in time. If you go over 21, you automatically lose.
(for a short video on how to play blackjack, click here: https://www.youtube.com/watch?v=_Dt1uZdlmYE)
After you have stayed, the computer will reveal its second card, and then it will automatically hit if its hand has a value of 16 or less. The computer will only stop hitting if the value of its hand is 17 or over. If it busts (goes over 21), you win. If not, compare both scores to determine a winner. It should show both players hands and scores at the end of each round.
Cards 2-10 have value equal to their number, jacks queens and kings all have a value of 10, and aces have a value of 1, unless it could be an 11 without your hand going over 21, in which case it has a value of 11 (you are smart so you will figure out how to do this - make sure it works for multiple aces also).
Betting in blackjack:
Before each round, you wager a certain amount (say 10 dollars). If the dealer wins, you lose your money. If you tie, there is no net change to your balance. If you win the round, you gain that much money (in addition to your initial wager) – so if you have 100 bucks and bet 10, you will have 110 after a win, 90 after a loss and 100 in case of a tie.
Here are two special cases that are available as a first move (but not after you have hit)
Double down – the player doubles his bet and gets one more card (an automatic hit basically). However, after receiving that card, the player may not hit any more.
[EXTRA CREDIT ONLY] Split – If you receive two cards of the same face (2 kings, or two 3’s, not a king and a queen), you may split the cards into two separate hands, adding a card to each of them, and adding a wager equivalent to your initial wager to the second hand. You will then play two hands (which you might also be able to split!) this round.
Video Poker:
In video poker, you are given a five card hand (you may want to represent this with an ArrayList). Your goal is to assemble the "best" possible five card hand. Once per game after you have seen your hand, you may discard any number of cards from your original hand and after you finish discarding them, then draw that many new cards from the deck. The computer then decides and prints out what you have (full house, flush, two pair, nothing, etc.) and you then get paid out according to your hand by viewing the chart below.
(for a short video on how to play video poker, click here: https://www.youtube.com/watch?v=fIWr_yonIZQ )
Betting in video poker:
Before each round, you place a wager, and after trading in cards, you receive one of these payments once the computer has determined your hand:
One pair: 1 to 1 (if the player bets 10 dollars, he wins 10 dollars, so his bankroll goes from 100 to 110). [note that in vegas, 1 pair will only pay out if your pair is jacks or better. But our Casinos will be more generous]
Two pair: 2 to 1
Three of a kind: 3 to 1 (so a three of a kind on a 10 dollar wager earns the player 30 new dollars)
Straight (five cards in a row): 4 to 1 (for the purposes of this program, we will assume that Aces are higher than Kings and Straights cannot "wrap around")
Flush (five cards of the same suit): 6 to 1
Full house (a three of a kind and a pair of something else): 9 to 1
Four of a kind: 25 to 1
Straight flush (5 cards in a row of the same suit, a straight and a flush): 50 to 1
Royal flush (10 through A of the same suit): 250 to 1
If your hand does not contain any of these, you lose your bet. Note that if your hand has multiple winners in it (for example, a full house also contains three of a kind and two pair), the program should only payout once (whichever is higher) and tell you which hand it is.
Suggestions/Hints:
***WORK ON THIS OUTSIDE OF CLASS. THERE IS AN ENORMOUS CORRELATION BETWEEN PEOPLE WHO STAY ON TRACK AND PUT IN WORK AT HOME AND PEOPLE WHO GET GOOD GRADES ON THIS PROJECT.***
Rather than just having a few huge methods do all the lifting, it might be easier and cleaner for you to write many smaller methods. Ideally, each method should only accomplish 1-2 tasks.
I would recommend writing at least the two following classes in addition to Casino:
Card – a playing card has a suit (hearts, diamonds, clubs or spades) and a value (2-10,jack, queen, king, ace).
Deck – a standard deck has 52 playing cards, 13 of each suit. An ArrayList may be a good idea here. Make sure you write a method to shuffle your deck (to be called whenever it gets low enough or when you start a new game) and to get the top card.
Ideally, you would use these same two classes for both blackjack and poker.
Make sure it is easy for the player to see what is going on in terms of which cards are in play, how much money he has, etc.
For poker, you probably want to have your program automatically sort the hands from lowest to highest or something like that. To do this, you may either look up a sorting algorithm online, adapt that to Card objects, and code that in, or try something like this: make a new empty arraylist, find the minimum in your original hand, put that first in the second list, then find the minimum of the remaining four in the original list, put that second in your new list, then find the minimum of the remaining three, put that third in your new list, etc.
For poker, I recommend separate methods for each possible way to win. For example, hasFullHouse or hasFlush would input a hand of 5 cards and determine if there is a full house or a flush.
To handle the money and make sure it carries over from game to game, it may help to make a Player or Wallet object that stores the amount of money you have. You do not have to do this, though some people have found this to be easier.
If you are having trouble with method calls, I found this resource online to be useful: https://drive.google.com/open?id=1EVtG_ffYSTx5tO5V-ddGHs96DPXdZBvF
I have purposefully left my directions vague to give you the freedom to figure out how to implement this on your own. You will need to decide which methods and classes you want to write and how you want to run the game itself. You may decide to write classes for BlackJack and Poker (this is what I did), or you may decide to write them as methods inside your Casino.java. Whatever you do, think carefully about data flow and sending variables back and forth. It is easiest to keep track of the money in Casino, and pass it to the other class as a method input or object, then have those methods return the amount gained or lost.
If you need help understanding how the games work, please ask me or use google/Wikipedia or whatever.
**If you are unsure where to start, I recommend writing your Card class, then a Deck class (that mostly would consist of an ArrayList of cards. Inside your constructor, it should create (with new) 52 cards and add them to the deck), and then start by programming a skeleton of blackjack (for instance, don’t worry about splitting or doubling down until later). You might also want to write in pseudocode in comments to help you get started. For instance, you could think of setting up your program like this for blackjack (and then filling in one part of the code at a time):
//get bet
// shuffle deck
// deal cards
// reveal one of computer cards, both of players cards
// have the player hit until he busts or is happy
// have computer play automatically.
// see who wins!
Recommended Timeline:
In lab from 11/15 to 12/5 (ten class days) to work on it. You will have a couple days to make Card/Deck, a week for blackjack and a bit less than a week for poker.
by start of class 11/17 - Card and Deck done and tested
by start of class 11/30 - One game (either Poker or Blackjack) done and somewhat tested
by start of class 12/5 - Both games done and somewhat tested
12/5 - Final detailed testing and troubleshooting (for instance, one good way to test poker is to fix your game so it automatically deals you a straight flush or a full house and then check to make sure the payout is correct), check yourself against the rubric to make sure everything is in order.
end of day 12/5 - Everything is completed and turned in
Extra Credit Opportunities:
-Program in another game (like slots and/or Baccarat, Keno, War, etc. or other games of your choosing, see me to OK individual options) your casino offers!
-Program in a split function into your BlackJack program (make sure to let me know if you do this, as I may run your blackjack 5-10 times and just never get a pair).
-Look up how to input from/output to text files so you can implement a high scores list.
Scoring:
This project will be worth 30 points and will be scored on the following rubric:
___/3pts: I can easily switch between games, my money stash carries over until I select to quit out.
___/2pts: deck sets up and shuffles correctly
Blackjack (13 points):
___/3pts: program allows the player to hit or stay just fine.
[EC]___/2: split works correctly
___/2pts: double down works correctly
___/3pts: computer plays appropriately (including not playing if you bust or get a 21)
___/5pts: program shows both hands, correctly values hands (including aces) and figures out who wins
Poker (12 points):
___/5pts: I am able to trade in cards if desired
___/7pts: your program figures out what I have, prints that out, and pays out correctly.
___Extra Credit: Up to 10 points for extra games
NOTE: NO LATE WORK (or revisions) WILL BE ACCEPTED FOR THIS ASSIGNMENT. If your program does not compile, you will receive a 0% on this assignment.
Have fun!!