Question: Use the following code to implement a Deck Object. When finished, add the following features: A. Add a method shuffle to the Deck Class. Call

Use the following code to implement a Deck Object. When finished, add the following features:

A. Add a method shuffle to the Deck Class. Call the method from the Main class to verify that the deck is indeed shuffled.

B. Add a Hand Class that contains an array of 5 Card references. Have the program Deal the Hand two cards and display them for the user. Tell the user how many points they have and ask them if they would like another card or not. Continue to allow the player to add cards until they reach 5 cards, or the total is greater than 21.

C. Adjust the Card class to allow Aces to count as 11 to start. If the Hand Class has a value greater than 21, have the Hand Class check for Aces and reduce their point value to 1.

D. Have the program create a dealer Hand that the user can play against. The user should try to get as close to 21 without going over in an effort to beat the Dealer. If the Dealer has 16 or more the Dealer should stop taking cards.

public class Main {

public static void main(String args[]){

Deck d = new Deck();

d.print();

}

}

public class Deck {

Card[] cardArray = new Card[52];

Deck(){ //constructor

int suits = 4;

int cardType = 13;

int cardCount = 0;

for(int i = 1; i <= suits; i++)

for(int j = 1; j <= cardType; j++){

cardArray[cardCount] = new Card(i,j);

cardCount++;

}

}

public void print(){

for(int i = 0; i < cardArray.length; i++)

System.out.println(cardArray[i]);

}

}

public class Card{

String suit,name;

int points;

Card(int n1, int n2){

suit = getSuit(n1);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!