Counting Bridge Hands
Assignment
You are to write a program that simulates the dealing of four thirteen-card
hands from a shuffled deck. The program should then determine how many
points each of the four hands is worth based on the following criteria:
-
Each Ace is worth 4 points.
-
Each King is worth 3 points.
-
Each Queen is worth 2 points.
-
Each Jack is worth 1 point.
-
A doubleton suit (exactly two cards in that suit) is worth 1 points.
-
A Singleton suit (exactly one card in that suit) is worth 2 points.
-
A void suit (no cards in the suit) is worth 3 points.
The program will deal 4 hands and neatly display them along with the associated
point totals. It is customary for the four hands to be labeled "North",
"East," "South," and "West." The program should also print whether each
hand has an "opening bid". A hand may open if it meets the following two
conditions:
-
The hand must have at least 13 points.
-
The hand must have either:
-
A suit with at least 5 cards.
-
A suit with 4 cards including at least one honor (Ace, King, Queen, or
Jack).
Even more points can be obtained by actually having the computer simulate
a complete game of bridge ;-).
The dealing of hands will be done either at random or from a deck supplied
as an input file. Your program should begin by asking the user whether
to use a random deck or one constructed from a file. If from a file, the
user will be prompted for a file name from which to read the deck. The
file will consist of number/character pairs indicating the cards. For example:
3 d
2 d
8 c
1 s
.
.
.
Note that the cards should be dealt from the deck one at a time to each
hand. So each hand gets one card, then each hand gets a second card, etc.
Your program should be menu driven. When run, it presents the user with
three options: Random deal, Read from file, or quit. If the user selects
read from file, the program should then prompt for the name of the file
containing the definition of the deck. After running the simulation, the
program should return to the menu to allow another run.