CIT 590 Assignment 4: A Hand of Bridge
Spring 2009, David Matuszek
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.
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. Any player can act as the "dealer."
Here's how it goes:
Next, thirteen "tricks" are played. Each trick proceeds as follows:
After doing the above 13 times, all cards have been played and the hand ends. The program ends, too.
There is no strategy to this game, it isn't scored, nobody wins or loses. It's a stupid game, OK?
After the cards are shuffled and dealt:
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 "leads"--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.
I will suggest what classes you need (and you may have more, if you like), but it's up to you to decide what their instance variables and their methods should be.
Use the objects you define to play a hand of "bridge."
Print out at least:
Bridgebridgeclass Bridge -- contains the main method.
Controls the game. class Card -- represents one card.
Has a suit and a value. You can find out
what the suit and value are, but you can't change them. class Player -- represents a player.
Every player knows how to shuffle, how to deal, and how to play cards.Bridge_yourName_partnersName The above are requirements. You may have additional classes and methods as needed, and they should be documented and unit tested as appropriate.