Computer Science 325.001
Software Engineering
Spring 201
3
Homework
Assignment
2
(25 points)
Due Date: T
ue
sday,
Febr
uary
1
2
, 201
3
Due on your drop

box by
4:30 P
M
Recall the rules of the
“
Hearts
”
card game:
This game
is
played by
four
players
, using
a standard 52

card. The dealer deals all of the cards to the players
, so each player
starts with 13 cards
.
Passing
After looking at his or her hand, each player chooses three cards and passes them face down to another player. All players mu
st
pass their
own cards before looking at the cards received from an opponent.
The passing rotation is: (1st hand) to the player on
your left, (2nd hand) to the player on your right, (3rd hand) to the player across the table, (4th hand) no passing. The rota
tion then
rep
eats until the game ends.
Tricks
The player holding the 2 of
C
lubs after the
first
pass plays that card to start the first trick.
Each player must follow suit if possibl e. If
a player has no cards in the suit led, a card of any other suit may be discarded. Exception: If a player has no clubs when th
e first
trick is led, a heart or the
Queen of Spades
(the “Black Maria”)
cannot be pla
yed.
The highest card of the suit led wins a trick. The winner of the trick keeps all cards won in a single stack in front of hims
elf or herself,
face down. The winner of a trick starts the next trick.
Hearts may not be led until a heart or the
Black Maria
has been played (this is called "breaking" hearts). The
Black Maria
can be
led at any time.
Scoring
Use a score sheet with a column for each player. At the end of each hand, count the number of hearts each player has taken, a
s well
as the Black Maria.
Hearts are 1 point each; the Black Maria is 13 points.
If one player has won all 13 hearts and the Black Maria (this is known as
“shooting the moon”
), that player can choose to subtract
26 points from his or her score, or to add 26 points to every other pl
ayer's score.
When one player reaches or passes
100 points
, the game ends. The player with the lowest score wins.
Let’s examine an example hand…
Original Deal:
It’s the first pass, so everyone
passes three cards to the person on their left. For this example, everyone just passes their last three
cards.
The Pass:
Blue has the 2 of
C
lubs, so Blue starts the first tri ck with that card
.
Orange plays the King of Clubs, Green plays the Ace of Clubs,
and Gray plays the Queen of Clubs, so Green wins the trick.
Green won the first trick, so Green starts the second trick with the King of Di amonds. Gray plays the 8 of Diamonds, Blue pla
ys the
Ace of Diamonds, and Orange plays the
Jack of Diamonds, so Blue wins the trick.
Blue won the second trick, so Blue starts the third trick with the Queen of Diamonds. Orange plays the 9 of Diamonds, Green p
lays
the 10 of Diamonds, and Gray plays the 7 of Diamonds, so Blue again wins the trick.
Blue won the third trick, so Blue starts the fourth trick with the Jack of Spades. Orange plays the 8 of Spades, Green plays
the 10 of
Spades, and Gray plays the 4 of Spades, so Blue again wins the trick.
Blue won the fourth trick, so Blue starts the fifth trick with the 2 of Spades. Orange plays the 3 of Spades, Green plays the
9 of
Spades, and Gray plays the Ace of Hearts (since Gray has no Spades)
thus “breaking Hearts”
, so Green wins the trick.
Green won the fifth trick, so Green starts the sixth trick with the 5 of Clubs. Gray plays the Jack of Clubs, Blue plays the
8 of Cl ubs,
and Orange plays the 9 of Clubs, so Gray wins the trick.
Gray won the sixth trick, so Gray starts the seventh trick with the 10 of Clubs. Blue plays the 7 of Clubs, Orange plays the
4 of
Clubs, and Green plays the Queen of Spades, the Black Maria (since Green has no Clubs), so Gray
again
wins the trick.
Gray won the seventh tri ck, so Gray starts the eighth trick with the 3 of Diamonds. Blue plays the 6 of Diamonds, Orange play
s the
5 of Diamonds, and Green plays the 2 of Diamonds, so Blue wins the trick.
Blue won the eighth trick, so Blue starts the ninth trick with the 5 of Spades. Orange pl ays the Ace of Spades, Green plays t
he 7 of
Spades, and Gray plays the Jack of Hearts (since Gray has no Spades), so Orange wins the trick.
Orange won the ninth trick, so Orange starts the tenth trick with the 6 of Hearts (since Hearts has al ready been broken). Gre
en
plays the 3 of Hearts, Gray plays the 5 of Hearts, and Blue plays the 2 of Hearts, so Orange
again
wins the trick.
Orange won the tenth trick, so Orange starts the eleventh trick with the 7 of Hearts. Green plays the 9 of Hearts, Gray plays
the 4
of Hearts, and Blue plays the 8 of Hearts, so Green wins the trick.
Green won the eleventh trick, so
Green starts the twelfth trick with the 6 of Spades. Gray plays the 6 of Clubs (since Gray has no
Spades), Blue plays the Queen of Hearts (since Blue has no Spades), and Orange pl ays the King of Spades, so Orange wins the
trick.
Orange won the
twelfth tri ck, so Orange starts the last trick of the hand wi th the 10 of Hearts. Green plays the King of Hearts,
Gray plays the 3 of Clubs, and Blue plays the 4 of Diamonds, so
G
reen wins the trick.
Examining each player’s won tricks at the end of the han
d reveals a score of 13 for Gray (due to the Black Maria), 0 for Blue, 6 for
Orange, and 7 for Green. On the next hand, the pass will go to the right instead of the left.
Develop a
complete
UML class diagram for the cards and their interactions if this game is implemented as a program. Include the
obvious
classes (a single playing card,
a deck of cards, a player, a dealer), and make sure that the necessary game items (a
player
’
s hand
, a
pass, a trick
) are available as either classes or attributes, whichever fits best. Include all appropri ate attributes,
operations (with parameters, i f applicable), visibilities, mul tiplicities, associations, aggregations, compositions, and gene
ralizati ons,
as well as any UML notes that would help to clarify your model.
Remember that you
’
re not implementing a program, just a model of the gameplay design. Al gorithmic details will not be included in
your model, but all obvious features (data and functionality)
must be included. For instance, a card must have a rank (Ace, 2, 3,
…
,
Jack, Queen, King) and a suit (
,
,
,
), and functionality will be needed to determine whether two cards have the same
suit
,
whether a hand of cards contains a
card
of
a particular
suit
, etc.
Use either
Microsoft Visio
or
IBM Rational Rose
to implement your diagram, and make sure to include a header containing your
name on your diagram.
While you may
discuss
this assignment with others, you are expected to develop your
own
model, to
not
show
your model to other class members, and to
not view
the models of your classmates.
Your completed homework assignment (in Microsoft Visio or IBM Rational Rose) is due on your
drop

box by 4:30 PM on T
ue
sday, February 12, 2013.
Enter the password to open this PDF file:
File name:

File size:

Title:

Author:

Subject:

Keywords:

Creation Date:

Modification Date:

Creator:

PDF Producer:

PDF Version:

Page Count:

Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο