o simulate a deck of playing cards o shuffle the deck o deal 5 cards into the hand o turn over the...
TRANSCRIPT
oSimulate a deck of playing cardsoShuffle the deckoDeal 5 cards into the handoTurn over the first cardoThe user must guess whether the next card is higher or lower
oTurn over the next card
oIf the user guesses correctly, the game continues
oIf the user guesses correctly 4 times, the game is over and the user wins
oIf the user guesses incorrectly, the game ends
Card Class• Face
• Suit
• Rank is based upon the Face
•Implements the Comparable Interface
•Methods
• Constructor
• public String getFace()
• public String getSuit()
• public int getRank()
• public int compareTo(Object other)
Hand Class• Represented as an array or as an ArrayList
•Methods
•Constructor
•public int getSize()
•public void addCard(Card c)
•public Card getCard(int i)
•private void changeCard(int pos,Card c)
•public void sort()
•private int findLowestIndex(int startIndex)
•public void printHand()
CardDeck Class•Represented as a two-dimensional array of Card objects
•Methods
•Constructor
•public void shuffle()
•public Card deal()
•public void printDeck()
The User Clicks Higher
The User Clicks Lower
The User Clicks Higher
The User Is Wrong! Game Over
•Blackjack
•War
•Games that use different card decks
•Extend the CardDeck class
•Games where Card ranks are different
•Extend the Card class