o simulate a deck of playing cards o shuffle the deck o deal 5 cards into the hand o turn over the...

10

Upload: coral-pearson

Post on 22-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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
Page 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

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

Page 3: 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

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)

Page 4: 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

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()

Page 5: 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

CardDeck Class•Represented as a two-dimensional array of Card objects

•Methods

•Constructor

•public void shuffle()

•public Card deal()

•public void printDeck()

Page 6: 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

The User Clicks Higher

Page 7: 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

The User Clicks Lower

Page 8: 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

The User Clicks Higher

Page 9: 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

The User Is Wrong! Game Over

Page 10: 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

•Blackjack

•War

•Games that use different card decks

•Extend the CardDeck class

•Games where Card ranks are different

•Extend the Card class