Ganderpoke Game
| Java software development mini project assignment, 2018. You can find the project code by clicking the Github icon. -> |
Context
Domain Statement
Workflow Models
Requirements
- Initiate a game of Ganderpoke
- Commence a game
- Ask for number of rounds
- Record number of rounds the player has entered
- Shuffle pack
- Set up the 5x5 square
- Deal remaining cards between players
- Record a player move (i.e., pick up card)
- Check that a move is legal according to the game rules
- Give feedback of game status to all players, e.g., indicating turns, whether to pick up cards etc.
- Calculate value of square
- Calculate score of players
- Check if all rounds are completed
- Compare scores of both players
- Announce the winner
- Reset to play another game
- Click play/start
- Enter number of rounds
- Play the game
- Pick up face down card from square
- Add the card to player’s hand
- Remove card from player’s hand
- Place card face-up onto the square in empty place
- Give next player to play
- Check winner
- Exit the game
- The target development language is Java 8, Standard Edition
- This should operate in the Netbeans 8 IDE within a Microsoft Windows environment
- The game should be designed to work for two
- A single PC or laptop with single mouse and/or keyboard should be used between two players
Use Cases
Use case: Start a game of Ganderpoke
|
Identifier and name |
UC01: Start a game of Ganderpoke |
|
|
Initiator |
Player1 |
|
|
Goal |
Start a game |
|
|
Start and stop points |
Player1 opens game, and Player1 is asked to play |
|
|
Main success scenario |
||
|
1 |
Player1 opens game |
|
|
2 |
The game displays start button |
|
|
3 |
Player1 clicks start |
|
|
4 |
System asks to enter number of rounds |
|
|
5 |
Player enters number of rounds |
|
|
6 |
The system(console) shuffles the pack of cards |
|
|
7 |
The system sets up the 5x5 square |
|
|
8 |
The system deals cards to each player |
|
|
9 |
Player2 is asked to turn away |
|
|
10 |
Player1 is asked to play |
|
Use case: Take a turn
|
Identifier and name |
UC02: Take a turn |
|
|
Initiator |
A player |
|
|
Goal |
Take a turn |
|
|
Start and stop points |
A player clicks card, The player ends turn |
|
|
Main success scenario |
||
|
1 |
A player clicks card from square |
|
|
2 |
The system adds card to the player’s hand |
|
|
3 |
The player selects card to replace from hand |
|
|
4 |
The player confirms card selection |
|
|
5 |
The system fills the empty space with the player’s card |
|
|
6 |
The player ends turn |
|
|
Extensions |
||
|
1a |
The player clicks face-up card and system prompts player to pick a
face-down card, if no Joker in hand |
|
|
1b |
The player clicks face-up card and system prompts player to pick
Joker card, if in hand |
|
|
1c |
The player clicks face-up Joker and system places replacement card
face-down |
|
|
5a |
If Joker is selected, card is placed face-up |
|
|
5b |
If Joker was picked up, card selected is placed face-down |
|
|
5c |
Normal card selected, card is placed face-up |
|
Use case: Check for winner
|
Identifier and name |
UC03: Check for winner |
|
|
Initiator |
System |
|
|
Goal |
Check who’s the winner |
|
|
Start and stop points |
System checks for end, System announces winner |
|
|
Main success scenario |
||
|
1 |
A player completes a turn (Inclusion in UC02) |
|
|
2 |
A check is made regarding the state of the cards in the square |
|
|
3 |
If all the cards are face-up, the game is over |
|
|
4 |
The system locates Poker combinations in all rows and columns |
|
|
5 |
The value is then calculated and summed |
|
|
6 |
The system checks for highest and lowest possible Poker
combination in players cards |
|
|
7 |
Player with highest Poker combination scores twice the value of
the square |
|
|
8 |
Player with lowest Poker combination scores once the value of the
square |
|
|
9 |
The system checks if the round number matches the number of rounds
selected |
|
|
10 |
If rounds match, the system checks if either player has a Joker
card |
|
|
11 |
If no player has a Joker card, system compares scores between
players |
|
|
12 |
System displays winner and results |
|
|
Extensions: |
||
|
3a |
If all cards are not face up, next player takes a turn |
|
|
10a |
If rounds don’t match, system refreshes for a new round |
|
|
11a |
If player holds a Joker card, player loses |
|
|
12a |
If player scores are same, system displays draw |
|
Class Diagram
|
Class |
Card |
A card in the Ganderpoke game Generalises Joker
and
NormalCard |
|
|
Attributes |
|
|
|
state |
The state of the card (face-up, face-down, in-hand) |
|
|
|
|
|
Class |
Player |
A person who is playing the game |
|
|
Attributes |
|
|
|
player |
Player number (Player1, Player2) |
|
|
score |
Score of the player |
|
|
|
|
|
Class |
Game |
A game of Ganderpoke |
|
|
Attributes |
|
|
|
rounds |
The number of rounds selected by the player |
|
|
currentRound |
The current round of play |
|
|
|
|
|
Class |
NormalCard |
A normal card in the Ganderpoke game Specialises Card |
|
|
Attributes |
|
|
|
suit |
Suit of the card (Diamonds, Hearts, Clubs, Spades) |
|
|
rank |
Rank of the card (A, 5, 6, 7, 8, 9, 10, J, Q, K) |
|
|
|
|
|
Class |
Joker |
A Joker card in the Ganderpoke game Specialises Card |
|
|
Attributes |
|
|
|
None |
|
|
|
|
|
|
Class |
PokerCombo |
A Poker combination |
|
|
Attributes |
|
|
|
combo |
The type of combination (“Straight Flush”, “Four of a Kind”, “Full
House”, “Flush”, “Straight”, “Triplet”, “Two Pair”, “One Pair”, “High Card”) |
|
|
score |
The score awarded to the player |
|
|
|
|
|
Class |
Square |
The 5x5 square displayed on the table/screen |
|
|
Attributes |
|
|
|
value |
Value of the square after the round has been completed |
|
|
|
|
|
Class |
Hand |
A collection of cards currently held by a player |
|
|
Attributes |
|
|
|
None |
|
|
|
|
|
|
Class |
Turn |
The event of a player taking a turn in the game |
|
|
Attributes |
|
|
|
player |
Current player taking a turn |
|
|
|
|
|
Class |
Pack |
The pack of cards used in the Ganderpoke game |
|
|
Attributes |
|
|
|
None |
|
|
|
|
|
|
|
|
|
Invariants
- If a Player object, Player1, is linked to a Game object, aGame, and the Game object, aGame, is linked to a Turn object, aTurn, then Player1 must be linked to aTurn.
- If a Card object, aCard, is linked to a Square object, aSquare, then the state in aCard must either be “face-up” or “face-down”.
- If a Card object, aCard, is linked to a Hand object, aHand then the state in aCard must be “in-hand”.
- A Square object, aSquare, has an initial value of 0, when linked to a Game object, aGame.
- If a PokerCombo object, aPokerCombo, has a combo of “Straight Flush”, then the score in aPokerCombo should be 10.
- If a PokerCombo object, aPokerCombo, has a combo of “Four of a Kind”, then the score in aPokerCombo should be 8.
- If a PokerCombo object, aPokerCombo, has a combo of “Full House”, “Flush” or “Straight”, then the score in aPokerCombo should be 5.
- If a PokerCombo object, aPokerCombo, has a combo of “Triplet”, then the score in aPokerCombo should be 3.
- If a PokerCombo object, aPokerCombo, has a combo of “Two Pair”, then the score in aPokerCombo should be 2.
- If a PokerCombo object, aPokerCombo, has a combo of “One Pair”, then the score in aPokerCombo should be 1.
- If a PokerCombo object, aPokerCombo, has a combo of “High Card”, then the score in aPokerCombo should be 0.
Dynamic Designs
Operation Specifications
|
Identifier |
OS 01, version 1.0 |
|
Context |
Player |
|
Signature |
pickUpCard(Card : aCard) : void |
|
Invariant |
True |
|
Precondition |
|
|
|
The selected card is face-down, and it is the current player’s
turn |
|
Postcondition |
|
|
|
The card is added to the player’s hand The square contains one less card
The player’s hand contains one more card
The player must select a card to replace
|
Operation Specification: Is Joker In Hand?
|
Identifier |
OS 02, version 1.0 |
|
Context |
Hand |
|
Signature |
jokerInHand(Hand : aHand) : boolean |
|
Invariant |
True |
|
Precondition |
|
|
|
All cards are face-up and the round is over |
|
Postcondition |
|
|
|
If player’s hand contains Joker, player has lost
If player’s hand does not contain Joker, score is calculated
End of round
|
Operation Specification: Place Card on Square
|
Identifier |
OS 03, version 1.0 |
|
Context |
Player |
|
Signature |
placeCard(Card : aCard) : void |
|
Invariant |
True |
|
Precondition |
|
|
|
The selected card is valid, and it is the current player’s turn |
|
Postcondition |
|
|
|
The card is placed on the empty spot The player’s hand has one less card
The square has one more card
It is the next player’s turn
|
Operation Specification: Compare Score
|
Identifier |
OS 04, version 1.0 |
|
Context |
Game |
|
Signature |
compareScore(Player p1, Player p2) : Player |
|
Invariant |
True |
|
Precondition |
|
|
|
The number of rounds is over, and players have been assigned a
score |
|
Postcondition |
|
|
|
A winner is announced
Game over
|
Operation Specification: Is Card Valid?
|
Identifier |
OS 05, version 1.0 |
|
Context |
Game |
|
Signature |
isValid(Card card1, Card card2) : boolean |
|
Invariant |
True |
|
Precondition |
|
|
|
The current cards are aState, aSuit and aRank card1 is connected to the square and card2 is linked to the
player’s hand
|
|
Postcondition |
|
|
|
If aState of card1 is face-up and card2 is a Joker, return true
If aState of card1 is face-down and card2 is a normalCard, return
true
If card1 is a Joker and aState of card2 is face-up, return true
Otherwise return false
|
Operation Specification: Check For Number of Rounds
|
Identifier |
OS 06, version 1.0 |
|
Context |
Game |
|
Signature |
setCurrentRound() : void |
|
Invariant |
True |
|
Precondition |
|
|
|
The current round has just ended |
|
Postcondition |
|
|
|
If the currentRound < rounds, the current round has been
incremented Otherwise the game is over
|
Sequence Diagrams
Object Diagrams
Implementation
The methods of all the classes have been
fitted into the above implementation model.
For the Card class, the
specialisations (Joker and NormalCard) have been omitted and cardType has been introduced with the
values restricted to being from the enumeration CardType.
The Turn class contains a link to a Player object which returns the current player (currentPlayer) who is playing their turn.
- If a Card object, aCard, has a cardType of Joker, then the suit in aCard must be “Not_relevant”.
- If a Card object, aCard, has a cardType of Joker, then the rank in aCard must be “Not_relevant”.
Links
- the Game class holds a link reference to a Square
- the Game class holds a collection of Player objects
- the Player class holds a link reference to a Hand
- the Square class holds a collection of Card objects
- the Hand class holds a collection of Card objects
- the Turn class holds a link reference to a Player
- the Pack class holds a collection of Card objects
Updated Class Descriptions
|
Class |
Card |
A card in the Ganderpoke game |
|
|
|
Attributes |
|
|
|
|
state |
The state of the card (face-up, face-down, in-hand) |
|
|
|
suit |
The suit of the card (“Diamonds”, “Hearts”, “Clubs”, “Spades”,
“Not_relevant”) |
|
|
|
rank |
The rank of the card (“A”, “5”, “6”, “7”, “8”, “9”, “10”, “J”,
“Q”, “K”, “Not_relevant”) |
|
|
|
cardType |
Type of card (Joker, NormalCard) |
|
|
|
Protocol |
|
|
|
|
State getState(Card c) |
|
|
|
|
CardType getCardType(Card c) |
|
|
|
|
|
|
|
|
Class |
Player |
A person who is playing the game |
|
|
|
Attributes |
|
|
|
|
player |
Player number (Player1, Player2) |
|
|
|
score |
Score of the player |
|
|
|
Links |
|
|
|
|
Hand hand |
References the linked Hand object |
|
|
|
Protocol |
|
|
|
|
Hand getHand() |
|
|
|
|
void pickUpCard(Card c) |
|
|
|
|
void placeCard(Card c) |
|
|
|
|
boolean isValid(Card c1, Card
c2) |
|
|
|
|
boolean jokerInHand() |
|
|
|
|
|
|
|
|
Class |
Game |
A game of Ganderpoke |
|
|
|
Attributes |
|
|
|
|
rounds |
Number of rounds the player has entered |
|
|
|
currentRound |
The current round of play |
|
|
|
Links |
|
|
|
|
Square square |
References the linked Square object |
|
|
|
Collection<Player> players
References a collection of the linked Player objects |
|
|
|
|
Protocol |
|
|
|
|
int getCurrentRound() |
|
|
|
|
void startGame() |
|
|
|
|
Player compareScore(Player p1,
Player p2) |
|
|
|
|
int getValue(Square s) |
|
|
|
|
void setScore(Player p) |
|
|
|
|
|
|
|
|
Class |
PokerCombo |
A Poker combination |
|
|
|
Attributes |
|
|
|
|
combo |
The type of combination (“Straight Flush”, “Four of a Kind”, “Full
House”, “Flush”, “Straight”, “Triplet”, “Two Pair”, “One Pair”, “High Card”) |
|
|
|
score |
The score awarded to the player |
|
|
|
Links |
|
|
|
|
None |
|
|
|
|
Protocol |
|
|
|
|
PokerCombo makeHighCombo(List<Card>
c) |
|
|
|
|
PokerCombo
makeLowCombo(List<Card> c) |
|
|
|
|
boolean
containsJoker(List<Card> c) |
|
|
|
|
|
|
|
|
Class |
Square |
The 5x5 square displayed on the table/screen |
|
|
|
Attributes |
|
|
|
|
value |
Value of the square after the round has been completed |
|
|
|
Links |
|
|
|
|
Collection<Card> cards References
a collection of the linked Card
objects |
|
|
|
|
Protocol |
|
|
|
|
void placeCard(Card c) |
|
|
|
|
void removeCard(Card c) |
|
|
|
|
void breakDownSquare() |
|
|
|
|
int getValue() |
|
|
|
|
List<Card> displaySquare |
|
|
|
|
PokerCombo
checkCombo(List<Card> l) |
|
|
|
|
|
|
|
|
Class |
Hand |
A collection of cards currently held by a player |
|
|
|
Attributes |
|
|
|
|
numOfCards |
The number of cards in the hand |
|
|
|
Links |
|
|
|
|
Collection<Card> cards References
a collection of the linked Card
objects |
|
|
|
|
Protocol |
|
|
|
|
void addCard(Card c) |
|
|
|
|
void removeCard(Card c) |
|
|
|
|
PokerCombo makeHighCombo() |
|
|
|
|
PokerCombo makeLowCombo() |
|
|
|
|
|
|
|
|
Class |
Turn |
The event of a player taking a turn in the game |
|
|
|
Attributes |
|
|
|
|
None |
|
|
|
|
Links |
|
|
|
|
Player currentPlayer References
the linked Player
object |
|
|
|
|
Protocol |
|
|
|
|
Player getCurrentPlayer() |
|
|
|
|
|
|
|
|
Class |
Pack |
The
pack of cards in the Ganderpoke game |
|
|
|
Attributes |
|
|
|
|
None |
|
|
|
|
Links |
|
|
|
|
List<Card> cards References
a collection of the linked Card
objects |
|
|
|
|
Protocol |
|
|
|
|
void shuffle() |
|
|
|
|
Void dealCardsToPlayer1() |
|
|
|
|
void dealCardsToPlayer2() |
|
|
|
|
Void dealCardsToSquare() |
|
|
User Interface and Interaction


State Diagrams
Testing
Acceptance Test #1
UC01 T1: Test that, a player enters a valid
integer for number of rounds to be played.
UC01 T2: Test that, the current round of
play is set to 1 when the players start playing.
Acceptance Test #2
UC02 T1: Test that, if a player clicks a
card is FACE_UP on the square, and the player has no Joker in hand, the system
prompts the user to select again. Invalid move.
UC02 T2: Test that, if a player clicks a
card is FACE_UP on the square, and the player has Joker in hand, the system
prompts the user to select the Joker.
UC02 T3: Test that, if a player clicks the
Joker on the square, the replacement card is placed FACE_DOWN.
UC02 T4: Test that, if a player clicks on a
normal card on the square, the replacement card is placed FACE_UP.
UC02 T5: Test that, if a player has
completed a turn, the current player switches to the other player.
Acceptance Test #3
UC03 T1: Test that, if a player has
completed a turn and the cards on the square are not all FACE_UP, that control
is transferred to the next player and the game continues.
UC03 T2: Test that, if current round is
less than number of rounds decided by the player, the system refreshes for
another round
UC03 T3: Test that, if a player holds a
Joker in their hand, they lose.
UC03 T4: Test that, if both players hold
the same score, the system displays a draw.
UC03 T5: Test that, if a player has no Poker combinations in their hand at the end of the round, they score 0.
Test Case: Picking up a card
|
Class Player |
|
|
Method pickUpCard(Card c)
|
Receiver and message player1.pickUpCard(A-HEARTS) |
|
Fixture and input A Square object square1 linked to twenty-five card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Player object, player1, is linked to square1. All the Card objects linked to square1 have the state as
FACE_DOWN. |
Expected result square1 is still linked with twenty-five Card objects. |
|
Class Player |
|
|
Method pickUpCard(Card c)
|
Receiver and message player1.pickUpCard(JOKER) |
|
Fixture and input A Square object square1 linked to twenty-five card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Player object, player1, is linked to square1. All the Card objects linked to square1 have the state as
FACE_DOWN. |
Expected result The Card object JOKER has the state FACE_UP. square1 is still linked with twenty-five Card objects. |
Test Case: Adding a card
|
Class Hand |
|
|
Method addCard(Card c)
|
Receiver and message hand1.addCard(A-HEARTS) |
|
Fixture and input A Square object, square1, linked to twenty-five card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Hand object, hand1, is linked to eight Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS). A Player object, player1, is linked to hand1. player1 has picked up the Card object, A-HEARTS (player1.pickUpCard(A-HEARTS)). The Card object A-HEARTS has the state FACE_UP. |
Expected result hand1 is linked to nine Card objects and contains the Card object, A-HEARTS. square1 is linked to twenty-four Card objects. The Card object, A-HEARTS, has the state IN_HAND. |
Test Case: Removing a card
|
Class Hand |
|
|
Method removeCard(Card c)
|
Receiver and message hand1.removeCard(SIX-SPADES) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, null, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. |
Expected result hand1 is still linked to nine Card objects The Card object, SIX-SPADES, has the state FACE_UP |
Test Case: Placing a card
|
Class Player |
|
|
Method placeCard(Card c)
|
Receiver and message player1.placeCard(SIX-SPADES) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, null, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. hand1 has removed the Card object, SIX-SPADES (hand1.removeCard(SIX-HEARTS)). The Card object SIX-SPADES has the state FACE_UP. |
Expected result hand1 is linked to eight Card objects and doesn’t contain the Card object, SIX-SPADES. The Card object, SIX-SPADES, has the state FACE-UP. square1 is linked to twenty-five Card objects and contains the
Card object, SIX-SPADES. |
Test Case: Is the card valid?
|
Class Player |
|
|
Method isValid(Card c1, Card c2)
|
Receiver and message player1.isValid(A-HEARTS,
SIX-SPADES) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, null, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, JOKER). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. hand1 has removed the Card object, SIX-SPADES (hand1.removeCard(SIX-HEARTS)). The Card object A-HEARTS has the state IN_HAND. The Card object SIX-SPADES has the state FACE_UP. |
Expected result Returns true.
|
|
Class Player |
|
|
Method isValid(Card c1, Card c2)
|
Receiver and message player1.isValid(JOKER,
SIX-SPADES) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, null). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. hand1 has removed the Card object, SIX-SPADES (hand1.removeCard(SIX-HEARTS)). The Card object JOKER has the state IN_HAND. The Card object SIX-SPADES has the state FACE_UP. |
Expected result Returns true.
|
|
Class Player |
|
|
Method isValid(Card c1, Card c2)
|
Receiver and message player1.isValid(SIX-SPADES,
JOKER) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, null). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. hand1 has removed the Card object, SIX-SPADES (hand1.removeCard(JOKER)). The Card object JOKER has the state FACE_UP. The Card object SIX-SPADES has the state IN_HAND. |
Expected result Returns true.
|
|
Class Player |
|
|
Method isValid(Card c1, Card c2)
|
Receiver and message player1.isValid(SIX-SPADES,
JOKER) |
|
Fixture and input A Square object, square1, linked to twenty-four card objects (TEN-CLUBS, FIVE-HEARTS, TEN-HEARTS, A-SPADES, SIX-HEARTS, EIGHT-DIAMONDS, FIVE-SPADES, J-HEARTS, FIVE-CLUBS, SEVEN-DIAMONDS, TEN-DIAMONDS, A-DIAMONDS, A-HEARTS, EIGHT-HEARTS, Q-CLUBS, Q-HEARTS, K-SPADES, J-DIAMONDS, SIX-DIAMONDS, NINE-SPADES, NINE-CLUBS, EIGHT-CLUBS, K-DIAMONDS, NINE-HEARTS, null). A Hand object, hand1, is linked to nine Card objects (TEN-SPADES, SEVEN-HEARTS, SIX-SPADES, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. hand1 has removed the Card object, SIX-SPADES (hand1.removeCard(JOKER)). The Card object JOKER has the state FACE_DOWN. The Card object SIX-SPADES has the state IN_HAND. |
Expected result Returns false.
|
Test Case: Does the player’s hand contain a Joker?
|
Class Player |
|
|
Method jokerInHand(Hand h)
|
Receiver and message player1.jokerInHand(hand1) |
|
Fixture and input A Hand object, hand1, is linked to eight Card objects (TEN-SPADES, SEVEN-HEARTS, SEVEN-CLUBS, J-SPADES, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. |
Expected result Returns false.
|
|
Class Player |
|
|
Method jokerInHand(Hand h)
|
Receiver and message player1.jokerInHand(hand1) |
|
Fixture and input A Hand object, hand1, is linked to eight Card objects (TEN-SPADES, SEVEN-HEARTS, SEVEN-CLUBS, JOKER, FIVE-DIAMONDS, Q-SPADES, K-HEARTS, A-HEARTS). A Player object, player1, is linked to hand1. |
Expected result Returns true.
|
Test Case: Getting the highest Poker combination from a hand
|
Class Hand |
|
|
Method makeHighCombo()
|
Receiver and message hand1.makeHighCombo() |
|
Fixture and input A Hand object, hand1, is linked to eight Card objects (7-HEARTS,
8-HEARTS, 9-HEARTS, 10-HEARTS, J-HEARTS, Q-HEARTS, K-HEARTS, A-HEARTS). |
Expected result Returns new
PokerCombo(Combination.STRAIGHT_FLUSH, 10) |
Test Case: Getting the lowest Poker combination from a hand
|
Class Hand |
|
|
Method makeLowCombo()
|
Receiver and message hand1.makeLowCombo() |
|
Fixture and input A Hand object, hand1, is linked to eight Card objects (7-HEARTS, 8-HEARTS, 9-HEARTS, 10-HEARTS, J-HEARTS, Q-HEARTS, K-HEARTS, A-HEARTS). |
Expected result Returns new
PokerCombo(Combination.FLUSH, 5)
|
Test Case: Does a hand contain a Joker?
|
Class Hand |
|
|
Method containsJoker()
|
Receiver and message hand1.containsJoker() |
|
Fixture and input A Hand object, hand1, is linked to eight Card objects (7-HEARTS, 8-HEARTS, 9-HEARTS, 10-HEARTS, J-HEARTS, Q-HEARTS, K-HEARTS, A-HEARTS). |
Expected result Returns false.
|
Test Case: Compare score between two players
|
Class Game |
|
|
Method compareScore(Player p1, Player
p2)
|
Receiver and message game.compareScore(Player
player1, Player2 player2) |
|
Fixture and input A Game object , game, is linked to List<Player> players, which contains references to two Player objects, player1 and player2. player1 has a score of 432. player2 has a score of 328. |
Expected result Returns player1
|




























