CIT 591 Assignment 4: Play a Hand of Bridge
Fall 2013, David Matuszek


The General Idea

Play a hand of bridge.

The object of this assignment is to play legally, that is, according to the rules of bridge. Playing well, and attempting to win the game, is outside the scope of this assignment.

Very short summary

There are four players. Each player gets 13 cards. A suit and a player are chosen (randomly). The chosen player plays the first card, and each of the other players then plays a card (of the same suit, if possible). The player who played the highest card wins the "trick" (the four cards just played) and plays the first card of the next trick.

The assignment: Shuffle and deal the cards, then play the hand (13 tricks). Follow the rules for what cards may be played, but don't try to implement any strategy or any scoring.

The rules

Cards and the card deck are as described in the previous assignment. In fact, the Card class (as given in Bid.scala) can be used without any changes.

There are four players, whom we will call "North", "East", "South" and "West".

Here's how it goes:

  1. One of the players is chosen as the dealer. It doesn't really matter which one; every player should have the ability (a method) to deal.
  2. The dealer shuffles the deck, then deals the cards; that is, she gives 13 cards to each player, including herself. The 13 cards held by a player are that player's hand. (Note: the deal method in Bid.scala is inadequate for dealing more than one hand.)
  3. A trump suit is chosen: One of "Clubs", "Diamonds", "Hearts", "Spades", and "No Trump". "No trump" means just what it sounds like: No suit is trump. This suit will remain trump until the entire hand has been played.
  4. One of the players is chosen (again, randomly) to "lead," that is, to play the very first card.

Next, thirteen tricks are played. Each trick proceeds as follows:

  1. The player chosen to lead plays the first card.
  2. Proceeding clockwise (N → E → S → W → N), each of the remaining players then plays a card.
  3. When all four players have played a card, the player who played the highest card "takes the trick".
  4. The player who took the trick is the player that will lead the next trick.

After doing the above 13 times, all cards have been played and the hand ends.

There is no strategy to this game, it isn't scored, nobody wins or loses.

Partial Example (one trick)

After the cards are shuffled and dealt:

Cards played Result
  1. North plays the 5 of Hearts
  2. East plays the 8 of Hearts
  3. South (who has no Hearts) plays the Queen of Diamonds
  4. West plays the 4 of Hearts
If the trump suit is anything but Diamonds, East wins the trick.
If the trump suit is Diamonds, South wins the trick.

Your program should detrmine who won the trick, but it does not have to keep track of all the tricks.

Your assignment

Create these classes and objects:

We will be running tests on all the methods mentioned above, except main, which we will test "manually." Therefore, be sure that all your methods are in the right places, spelled and capitalized as shown, and have the correct parameter types and return types.

Please name your file bridge_hand.scala.

Due date

Submit your team's program, as a single .scala file, to Canvas by 6am next Friday, September 27. Decide which of you is going to turn in the assignment, and make only one submission for the two of you. Make sure both of your names are in comments at the top of each file.