Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Draw the product (if any) of each reaction. a. Cu2+

Answered: 1 week ago