ITCS 1213: Create a solution designed to play Blackjack

25.00 $

Category:

Description

5/5 - (1 vote)

ITCS 1213

In this project you will create a solution designed to play Blackjack. We will use simple rules of the game. Assume there exists a player and a dealer. The winner of the game is the player who gets closest to 21 without exceeding 21 or “going bust”. If both players have the same points, then neither player wins the hand. An ace has a value of 1 or 11. Face cards have a value of 10. The dealer must take a card if the dealer’s hand is worth 16 or less. The dealer may not take a card if the hand is worth 17 or more. As the player, you may take a card at any time.
Allow the user to play as many hands as he/she wants.
Keep track of how many hands the dealer wins and how many hands the player wins.
How to get started;
Create a class called Card. The card has three fields, value and suit, face.
The card class has a constructor that takes three values for the three fields.
Do not create a no-args constructor. The Card class has three get methods to return the values of each of the fields.
The Card class has a toString( ) method.
The Card class has a compareTo( ) method that uses the value of the card to determine the ordering. For this implementation the ordering is as follows: (high to low) A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2
Create a class called Deck. A deck has two fields- an array of Cards and an int which holds the subscript of the Card at the top of the deck. The Deck class will have only one constructor, which will create the array. Try to think of a way to code this without writing 52 statements.
The Deck class also has a method getTopCard( ) which returns a copy of the Card that is at the top of the array. The Deck class has a method called shuffle( ) which shuffles the array of Cards. To shuffle, generate random numbers and use these to exchange array elements. Exchange 1000 times in this method. If you are unsure of how to generate a random number after reading the Java API documentation on the Random class, please ask in class.
Create the driver class – call it Game21.
This is where your game logic will go. As a hint, you will need to create one Deck instance and then call the shuffle method( ) for each. When you are testing as you write, before you shuffle( ) you may want to print out the entire Deck to make sure you have created the array of Cards correctly.
Each player is dealt two cards to start. Then the rules stated above are followed. Only the user has the choice whether to deal another card or quit. The dealer (computer) must be dealt another card from its deck if its total is 16 or under and must quit if its hand is 17 or over.
Once a hand is won, either by the computer or the player, allow the player to decide if he/she wants to play another hand. Keep a running total of the number of hands won by the computer and the number of hands won by the player.

  • ITCS-1213.zip