CIT 591 Fourth Assignment: A Hand of Bridge
CIT 591, David Matuszek, Fall 2002

Purposes:

The Idea:

Play a hand of bridge.

Don't worry--you don't actually have to know bridge in order to do this assignment. In fact, this assignment is "inspired by" bridge in the same way that a movie is "inspired by" a true story. I'm providing some very simplified rules. If you do know how to play bridge, please accept my apologies--but the assignment is still to write a program to play this version, not the real game.

The rules:

A deck of cards consists of 52 cards--13 each in four different suits. The four suits are called Spades, Hearts, Diamonds, and Clubs. Each card in a suit has a number from 1 to 13. Hence we have cards such as "the 4 of Spades" or "the 13 of Diamonds." (We do not have Ace, Jack, Queen, King cards, just numbered cards.)

There are four players, whom we will call North, East, South and West. One of the players, called the "dealer," has extra actions ("shuffling" and "dealing") that she may take; otherwise, the dealer is just like the other players.

Here's how it goes:

  1. The dealer "shuffles" the deck. This randomizes the order of the cards, but there are still 52 different cards--no card ever occurs twice.
  2. The dealer "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."
  3. One of the players is chosen (I don't care how) to "lead," that is, to play the very first card.

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

  1. The chosen player plays the first card. "Playing a card" means removing it from her hand and letting the other players know which card it is. (In the real game, the card is placed face up on the table.) It is important to notice what the suit of this card is. In this simplified game, any card may be played as the first card of a trick (the players have no strategy or any idea of a "good" card to play).
  2. Each of the remaining players then plays a card. If a player has any cards of the same suit as the first card played, then she must "follow suit" (play a card of the same suit). If she has no cards of the same suit, she may play any card.
  3. When all four players have played a card, the player who played the highest-numbered card of the first suit played "takes the trick"--she collects and puts aside all four cards (we can ignore this bit--you don't need to keep track of the cards after the trick has been played). This player is then chosen to lead (play the first card of) 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. It's a stupid game, OK?

Partial Example (one trick):

After the cards are shuffled and dealt:

  1. North plays the 5 of Hearts
  2. East plays the 8 of Hearts
  3. South (who has no Hearts) plays the 12 of Diamonds
  4. West plays the 1 of Hearts

Since the first card played was a Heart, the player who played the largest Heart (East, with the 8 of Hearts) collects the four cards, and chooses any card from her hand (of any suit) to start the next trick. Whatever card East chooses, the other three players must play cards of the same suit, if possible.

Your assignment:

Figure out what the various classes and objects should be, and what their instance variables and their methods should be. There is no single "correct" design; any reasonable design will do. However, we may take off a lot of points for really bad design, such as (for instance) putting everything in a single class. The better your design, the easier your programming will be.

Use the objects you define to play a hand of "bridge."

Print out at least:

Due Date:

Wednesday, October 16, by midnight. Zip together all the relevant files, including at least all the.class and .java files, and submit them via Blackboard.