Question: Bridge Hand Case Study: Create a Java Program that uses Stacks to deal 4 hands in a game of Bridge. Create a Deck of Cards

Bridge Hand Case Study:

  • Create a Java Program that uses Stacks to deal 4 hands in a game of Bridge.
  • Create a Deck of Cards
    • Use a Stack to implement a deck of cards.
    • Import java.util.stack and use its classes and methods. Note that java.uitl.stack uses peek instead of top (as we did in class). Look up the documentation for java.uitl.stack to see what methods it contains and how to call them.
    • Create a Stack of cards that will hold strings.
    • Push new items to the stack (Use "Qclubs" for Queen of clubs and so on)
    • After your 'deck' has been created, print it out.
  • Shuffle the deck
    • Create another stack (or use the same stack) call the new stack, if you use one, ShuffledDeckStack or something like that

      Move the cards (randomly) from your original deck to the new, shuffled, one

      Use Random () from java.util.Random

      • Generate 52 random numbers between 0 and 51. (Hint: note the similarity to the indices of a 52-element array.)
      • Since we need an int, consider using the nextInt method of the Random class
    • Print out the Shuffled Deck
  • Create 4 Bridge Hands (consider making them stacks as well)

Call them, North, South, East and West. (Note that these are the traditional names for bridge hands).

Each hand must hold 13 cards.

  • Print out each of the 4 Bridge Hands

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!