Write a program to simulate a deck of cards with some basic

Write a program to simulate a deck of cards with some basic functionality. The easiest way to do this is to break it up into classes for a Card, a Stack, a Deck, and then a main class to demonstrate that the operations work successfully. A Card will have a suit and a value and it should include a toString() method which displays cards like “Queen of Hearts” or “Two of Spades.” You can do this however you’d like. You may want to look up how to use an enum if you have never used them before. A Stack can be implemented using an ArrayList or a LinkedList and must include methods such as pop, push, peek, and isEmpty. A Deck uses the methods available through the Stack. It should allow you to create a new Deck of 52 cards, shuffle those cards, and then deal some number.

Here are some hints: 1. The Collections super class (which List inherits from) contains a “shuffle” method which you can make use of in your Deck class 2. Your “deal” method can take an integer as input and remove (pop) that many cards from the deck. This also decreases the total size of the Deck.

Finally, your main class should do the following: 1. Create a deck of cards 2. Shuffle the deck 3. Deal some number of cards (either hard coded, or by user input) 4. Let the user know if the deck is out of cards

Solution

public category BlackjackHand extends Hand analysis of a (simple) blackjack hand. For demonstration functions,
* assumes that the hand consists of solely 2 cards, thus we\'re not implementing
* the whole logic for this...
* @return the worth of the hand per the foundations of Blackjack.
*/
public int evaluateHand() worth = 0;
for ( int i = 0; i < getNumberOfCards(); i++ ) ten )
thisValue = 10;
if ( thisValue == one )
thisValue = 11;
price += thisValue;
}
  
come value;
}
}

Write a program to simulate a deck of cards with some basic functionality. The easiest way to do this is to break it up into classes for a Card, a Stack, a Deck

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site