In a previous programming project, you figured out how to make a Card. A Card class is given to you. In this section, you will create the class Deck which represents a deck of 52 cards with no duplicates. Your Deck should inc
java poker游戏案例java poker游戏案例
lude the following (but you can add more depending on what you need):
Deck(): A constructor that creates a deck of 52 unique cards in whatever manner you wish.Card deal(): You should be able to take a card from the “top” of your deck and deal it. That card should not be dealt again until the deck is shuffled.
int numLeft(): A user should be able to ask the Deck how many cards are left in it (not-dealt) .void shuffle(): Return the deck to full and changes the order of the cards to be dealt Part A is AutoGraded by the Test Cases
Part B – Blackjack
You will now use your newly made Deck to play Blackjack. Implement the method playBlackjack in the Main.java file. Your game should follow the following rules.
The Player is dealt a card, then the Dealer. The Player is then dealt a second card , followed by the Dealer. Number cards are worth their Face value, Aces are worth 11 unless that would cause the Player to go over 21 (or “Bust”) at which point they are worth
The goal is to get as close to 21 as possible without going over (“Bust”). Whoever is closer to 21 at the end of the hand wins. In the event that the Player and the Dealer have the same score, they tie or “Push”.
If the Player is dealt 21 points (or “Blackjack”) (s)he instantly wins. If the Dealer is dealt “Blackjack”, the player instantly loses. If both Player and Dealer have “Blackjack”, they “Push”
If the Player is dealt less than 21, the Player may Hit or Stay. If (s)he Hits, (s)he is dealt another card. If (s)he “Busts”, then (s)he loses and is asked if ( s)he would like to play again. Otherwise, the Player may continue to hit until (s)he either Stays or “Busts”.
Once the Player’s turn is complete, the Dealer finishes. The Dealer MUST Hit until the Dealer has a score higher than 16. Once the Dealer is over 16, it Stays. If the Dealer “Busts” the Player wins.
If both Dealer and Player have stayed and not “Busted”, then the scores are compared and the winner declared. The Player may choose to Play Again. If the Player decides to Play Again, DO NOT RESHUFFLE THE DECK until all the cards have been dealt. Only reshuffle once all cards have been dealt from your deck.
Part B will be manually graded by me playing your game and/or reading your code
Part C – Yahtzee Lite
Yahtzee is a dice game that allows players to roll 5 six-sided dice in order to try to make sets or runs. You will design a lite version of Yahtzee and code it in the playYahtzee() method of the Main.java file. The rules you must implement are below.
There are two players: the User and the Computer. There are five User turns and five Computer turns to a game. During each turn, the current player roles dice. The player may then re-roll anywhere between 0 -5 of the dice up to two more times. Any dice that are not re-rolled are kept at their original face value. After the third roll, the player scores.
Scoring: For our simplified version, a player may have the following possible scores:
* A Pair: The sum of any two matching dice
* A 3 of a Kind: The sum of any three matching dice
* A 4 of a Kind: The sum of any four matching dice
* A Yahtzee: The sum of any five matching dice
* A Mess: The sum of any 5 dice.Once a score has been used, it cannot be used again for that game. To simplify your game, players HAVE to take the largest match possible. For example, if I roll a Yahtzee, I score it. On the next turn, if I roll another Yahtzee, I cannot use it for a 4 of a Kind or a 3 of a Kind, I either use my Mess, or I just lose the turn.
Mess is automatically used if either
1. No matches are found
2. A match has already been used
The User can choose which of the dice it wants to keep or re-roll each time during his/her turn. The Computer can use any logic you want to choose which dice to keep or re-roll. At the end of five turns, the player with the higher score wins. You should then ask the User if it wants to play again. If so, all the scores are wiped away, and the game begins anew.
Part C will be manually graded by me playing your game and/or reading your code