Download presentation
Presentation is loading. Please wait.
Published byJulia Hart Modified over 9 years ago
2
o Simulate a deck of playing cards o Shuffle the deck o Deal (5) cards into the hand o Turn over the first card o The user must guess whether the next card is higher or lower o Turn over the next card o If the user guesses correctly, the game continues o If the user guesses incorrectly, the game ends o If the user guesses correctly (4) times, the game is over and the user wins
3
Card Class o Face o Suit o Rank is based upon the Face o Implements the Comparable interface o Methods Constructor public String getFace() public String getSuit() public int getRank() public int compare To(Object other)
4
Hand Class o Represented as an array or as an ArrayList o 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()
5
CardDeck Class o Represented as a 2-dimensional array of Card objects o Methods Constructor public void shuffle() public Card deal() public void printDeck()
6
The User Clicks Higher
7
The User Clicks Lower
8
The User Clicks Higher
9
The User is Wrong! Game Over
10
o Blackjack o War o Games that use different card decks Extend the Card Class o Games where Card ranks are different Extend the Card Class
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.