Object-oriented Programming and Java
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP2396 Object-oriented Programming and Java
Assignment
Overview
This assignment tests your understanding of inheritance and polymorphism, and their
implementations in Java. You are going to implement a card game called Big Two. A number
of classes will be provided to aid your implementation. These include a Card class which
models a card, a CardList class which models a list of cards, a Deck class which models a
deck of cards, a CardGamePlayer class which models a card game player, and a BigTwoUI
class which models a user interface for the Big Two card game. A CardGame interface is also
provided to model a general card game. You may refer to their Javadoc for details of these
classes. You should NOT modify any of these provided classes and interface in completing
your assignment.
As a minimum requirement, you are required to implement the following classes: BigTwo,
BigTwoCard, BigTwoDeck, Hand, Single, Pair, Triple, Straight, Flush, FullHouse, Quad, and
StraightFlush. The BigTwo class models the Big Two card game logics. The BigTwoCard
class and the BigTwoDeck class model a card and a deck of cards used in a Big Two card
game, respectively. The Hand class models a hand of cards in general card games. The Single,
Pair, Triple, Straight, Flush, FullHouse, Quad, and StraighFlush classes model hands of legal
combinations of cards in a Big Two card game. You are free to introduce new instance
variables and methods to these classes. Besides, you are also free to design and introduce new
classes in the inheritance trees as appropriate. You are required to write Javadoc for all public
classes and their public class members.
Specifications
General game rules
To simplify your implementation, we will adopt the following rules:
• A standard 52 card pack is used.
• The order of ranks from high to low is 2, A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3.
• The order of suits from high to low is Spades, Hearts, Clubs, Diamonds.
• There are always four players in a game.
• Each player holds 13 (randomly assigned) cards at the beginning of the game.
• The player holding the Three of Diamonds will begin the game by playing a hand of
legal combination of cards that includes the Three of Diamonds. He/she cannot pass
his/her turn to the next player without making his/her move.
• Players take turns to play by either playing a hand of legal combination of cards that
beats the last hand of cards played on the table, or by passing his/her turn to the next
player.
• A player cannot pass his/her turn to the next player if he/she is the one who played the
last hand of cards on the table. In this case, he/she can play a hand of any legal
combination of cards regardless of the last hand he/she played on the table.
• A hand of legal combination of cards can only be beaten by another better hand of
legal combination of cards with the same number of cards.
• The game ends when any of the players has no more cards in his/her hand.
Legal combinations of Cards
• Single. This hand consists of only one single card. The only card in a single is
referred to as the top card of this single. A single with a higher rank beats a single
with a lower rank. For singles with the same rank, the one with a higher suit beats the
one with a lower suit.
• Pair. This hand consists of two cards with the same rank. The card with a higher suit
in a pair is referred to as the top card of this pair. A pair with a higher rank beats a
pair with a lower rank. For pairs with the same rank, the one containing the highest
suit beats the other.
• Triple. This hand consists of three cards with the same rank. The card with the
highest suit in a triple is referred to as the top card of this triple. A triple with a higher
rank beats a triple with a lower rank.
• Straight. This hand consists of five cards with consecutive ranks. For the sake of
simplicity, 2 and A can only form a straight with K but not with 3. The card with the
highest rank in a straight is referred to as the top card of this straight. A straight
having a top card with a higher rank beats a straight having a top card with a lower
rank. For straights having top cards with the same rank, the one having a top card
with a higher suit beats the one having a top card with a lower suit.
• Flush. This hand consists of five cards with the same suit. The card with the highest
rank in a flush is referred to as the top card of this flush. A flush always beats any
straights. A flush with a higher suit beats a flush with a lower suit. For flushes with
the same suit, the one having a top card with a higher rank beats the one having a top
card with a lower rank.
• Full House. This hand consists of five cards, with two having the same rank and three
having another same rank. The card in the triplet with the highest suit in a full house
is referred to as the top card of this full house. A full house always beats any straights
and flushes. A full house having a top card with a higher rank beats a full house
having a top card with a lower rank.
• Quad. This hand consists of five cards, with four having the same rank. The card in
the quadruplet with the highest suit in a quad is referred to as the top card of this quad.
A quad always beats any straights, flushes, and full houses. A quad having a top card
with a higher rank beats a quad having a top card with a lower rank.
• Straight Flush. This hand consists of five cards with consecutive ranks and the same
suit. For the sake of simplicity, 2 and A can only form a straight flush with K but not
with 3. The card with the highest rank in a straight flush is referred to as the top card
of this straight flush. A straight flush always beats any straights, flushes, full houses,
and quads. A straight flush having a top card with a higher rank beats a straight flush
having a top card with a lower rank. For straight flushes having top cards with the
same rank, the one having a top card with a higher suit beats the one having a top card
with a lower suit.
The BigTwo class implements the CardGame interface and is used to model a Big Two card
game. It has private instance variables for storing the number of players, a deck of cards, a
list of players, a list of hands played on the table, an index of the current player, and a user
interface. Below is a detailed description for the BigTwo class.