GAD225 HW: Cards and Decks

As discussed in class on Monday, you need to create a Card object from scratch, as well as a Deck object from scratch. I have provided you with a test class that you are not allowed to change. It can be found here.

Details on the Card and Deck requirements are found below. I've added 2 small things that we didn't discuss in class, so check it out.


  • suit - an integer, 0 - 3, each representing one of the four suits (clubs, diamonds, hearts, spades)
  • rank - integer, 1 - 13, aces are 1, 2-10 are obvious, 11 jack, 12 queen, 13 king
  • facing - boolean - true if the card is face up, false if face down.

It is highly recommended that you create constants for suits and ranks to make your life easier.


The constructor should take in a variable for each bit of data. facing should have a default of true.

  • Getters- I should be able to get the data for the suit and rank, but only if the card is face up. I should always be able to tell if it is face up or not. NO SETTERS, except for facing.
  • flip - a function that toggles the facing variable
  • isValid - returns true if the card's suit and rank are in the appropriate ranges (so a card with a suit of 32 is invalid)
  • toString - returns a version of the card as a string. Something like "Ace of Spades" or "Three of Clubs". Should use actual words for both suit and rank.
  • equals(another card) - This compares the suit and rank of two cards to see if they are identical. Returns true if BOTH match


  • cards - an array - an array holding all the cards in the deck
  • topSpot - int - The spot in the array where the top card is (0 is the bottom, as people draw cards from the deck, the top spot changes to indicate where the top is).

The constructor takes in no variables. It initializes all 52 cards to fill the array (use loops). All cards are face down. It should construct a full, valid deck.

  • isValid - Has three criteria for valid decks: They must not be bigger than 52 cards. All cards in the deck must be valid. There must be no duplicate cards
  • shuffle - This will shuffle the cards, putting them in a random order
  • Print - This will print out all the cards in the deck
  • FlipAll - This will flip all the cards in the deck
  • DrawTopCard - this will return the topmost card in the deck (and remove it from the deck)
  • DrawBottomCard - this will return the bottom card in the deck ( and remove it)
  • AddCardToTop - This will add the supplied card to the top of the deck
  • AddCardToBottom - This will add the supplied card to the bottom of the deck
  • CountCards - this will return the number of cards remaining in the deck


We are now using these cards to make Blackjack. Your main class must support playing hands until the player runs out of money. The player must be able to hit, stand, or double down (extra credit for split). The dealer stands on anything less than 17. Affect player's bankroll, and then they can play another hand.

This should use a BlackjackCard (extend Card), and that class should have some data tracking each card's value in the game of Blackjack (i.e. 10s, Js, and Qs, are all worth 10).

It should also use a BlackJackDeck, which is probably identical to Deck, but uses BlackJackCards rather than regular ones.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • Fark
  • Google Buzz

Tags: , , , , ,

Comments are closed.