BEST代写-线上留学生作业代写 & 论文代写专家

成立于2015年的老牌留学生代写品牌-BEST代写提供超过百门冷热门留学学科的作业和论文代写服务。全网BEST原创,高质,准时的留学生代写。

C++代写 | AST21105 Object-Oriented Programming & Design

C++代写 | AST21105 Object-Oriented Programming & Design

这个program是运动C++的类,对象,构造函数,继承和标准模板库,并完成一个纸牌游戏
AST21105 Object-Oriented Programming & Design
Individual Programming Project
A. Objective
The objective of this project is to practice your programming skills on classes, objects, constructors, inheritance,
and standard template library that you have learned in class. Upon completion of this project, you should be
able to:
l Demonstrate your understanding on how to define user-defined data types using classes, initialize and use
objects for storing data, and enhance reusability of code using inheritance and standard template library.
l Construct a C++ program modularly from small pieces using objects and member function calls.
B. Task
l In this project, you are required to implement a Big-Two card game.
l To get started, you should read the specifications carefully.
l Also, your program must consist of the major classes described in the section “Design
Specifications”.
l Submit your program files, .cpp and .h via Canvas, by 23:59 on May 4 2020.
C. Marking Criteria
Grading Component Marks
1 Correctness of the program 20
2 User-friendliness of User Interface 5
4 Documentation of codes (whether the program is well commented to aid understanding) 5
30
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
2
D. Game rules
General game rules:
In this project, you are asked to implement a computer card game known as Big-Two or “Choi Dai Di”
in Cantonese. The aim of the game is to get rid of all the cards in hands.
In a typical Big-Two game, a deck of shuffled cards is distributed uniformly to 4 players by the dealer.
The player who got the diamond of 3 will be given the opportunity to play first and s/he can play a single
card or play a combination of cards (e.g. a pair of cards with the same card value, 3 cards with the same
card values, or 5 cards in a straight, flush, full house, four of a kind plus one card, or straight flush. The
details of the all these combinations will be further explained soon.)
After this, the player who sits next to the first player in the counter-clockwise / anti-clockwise direction
around the table is the next one to play, and he / she can place something “higher” than the last player’s
play (while should maintain the same number of cards). Alternatively, he / she can pass his / her turn and
let the next player to play. In case, if all the three players pass their turns, then the player who gives the
last play can start a new round and play anything he / she wants (i.e. single card or a combination of
cards).
Rank of a single card:
Note that the rank of a single card is determined by its card value. The card with higher value beats the
other card with lower value. If there is a tie, the card with higher suit beats the other.
Rank of cards: 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < J < Q < K < A < 2
Rank of suits: Diamond ¨ < Club § < Heart © < Spade ª
Therefore, it is easy to find that 2ª is the highest and 3¨ is the lowest.
Rank of three-of-a-kind:
Three-of-a-kind refers to any three cards of the same card value. The rank of three of a kind is
determined by its card value. This means the three with higher card value beats the other
three-of-a-kind (e.g. the triples with Q©-Q§-Q¨ beats Jª-J©-J§).
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
3
Combination of five cards and their rank:
There are a number of valid five cards combinations and they are named as:
1. Straight (also called snake):
Example: 2¨-3§-4©-5ª-6¨, 9ª-10¨-J©-Q¨-K§, etc.
A straight refers to any 5 cards in a sequence (but not all the same suit). The rank of straight is determined
by the highest card value (e.g. 10ª-Jª-Q¨-K©-A§ < 2¨-3ª-4¨-5©-6©, since 2¨ beats A§). When
there is a tie, the suit of the highest card value is used to determine the rank (e.g. 10ª-Jª-Q¨-K©-A§ >
10©-J¨-Q©-K§-A¨, since A§ beatsA¨)
2. Flush (also called flower)
Example: 9©-7©-6©-5©-3©, 2§-4§-6§-9§-J§, etc.
A flush refers to any 5 cards of the same suit, but not in a sequence. The rank of flush is determined by
the highest suit (e.g. 9©-7©-6©-5©-3© > 2§-4§-6§-9§-J§, since © beats§). When there is a tie,
the card value of the highest card is used to determine the rank (e.g. 2§-4§-6§-9§-J§ beats A§-K§-
Q§-10§-7§, since 2 beats A).
3. Full house (also called fullen)
Example: 9§-9©-9¨-4©-4¨, 8¨-8©-8§-Kª-K¨, etc.
A flush refers to a three-of-a-kind plus a pair. The rank of full house is determined by the value of the
three-of-a-kind (e.g. 9§-9©-9¨-4©-4¨ beats 8¨-8©-8§-Kª-K¨, since 9 beats 8).
4. Four of a kind plus one card (also called bomb or quads)
Example: 9ª-9©-9§-9¨-4¨, 8ª-8©-8§-8¨-K¨, etc.
A four-of-a-kind refers to any set of four cards of the same rank, plus one card. The rank of
four-of-a-kind is determined by the card value of the 4 card set (e.g. 9ª-9©-9§-9¨-
4¨ beats 8ª-8©-8§-8¨-K¨, since 9 beats 8).
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
4
5. Straight flush
Example: Aª-Kª-Qª-Jª-10ª, 8ª-7ª-6ª-5ª-4ª, etc.
Astraightflush refersto five cardsin sequence and in the same suit, thisis also called a composite
of straight and flush. The rank of straight flush is determined by the suit (e.g. Aª-Kª-Qª-Jª10ªbeats 8ª-7ª-6ª-5ª-4ª). If there is a tie, then the suit is used to determine the rank (e.g.
8ª-7ª-6ª-5ª-4ª beats 8©-7©-6©-5©-4©, since ª beats©).
E. More game rules
Note that a combination can only beat another combination with the same number of cards. In other
words, a single card can only beat single card, a pair beats a pair, and a three-of-a-kind beats a
three-of-a-kind. However, a combination of five cards can beat five cards of a stronger type. The
following shows the rank of five cards.
Last card
When a player has only one card left in hand, an announcement has to be made to inform all the other
players.
Game wins or loses
The first player who successfully gets rid of all his / her cards in hand wins the game and the other
players lose. When this happens, the game ends and the hand in each player is scored by the dealer.
Scoring
At the end of the game, the players who got cards in hands score penalty points. There are a number of
different ways in counting the penalty. The following is the most typical one and is adopted in this
assignment.
Penalty per card Number of cards
1 point 9 cards or fewer n hand
2 points 10, 11 or 12 cards in hand
3 points All 13 cards left in hand
Straight (Snake)
Flush (Flower)
Full house (Fullen)
Four of a kind plus one card (Bomb)
Weaker
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
5
F. Design Specification
The following shows you the design of program. Your Big 2 game should have AT LEAST the
following classes.
The UML class specifications of classes as shown in the table above are as follows:
Card
Class Base Class Description
Card / A Big 2 card
Hand / A Big 2 hand, which is a collection of Card objects.
Play / A Big 2 play, which consists of a set of cards of the play (i.e. can be a single
card, a pair of cards, a kind of three, a combination of five)
Deck / A Big 2 deck, which consists of a collection of Cards. Note that it consists
of 52 cards at the very beginning.
Dealer /
A Big 2 dealer, which holds a deck of 52 cards at the very beginning of the
game and he / she distributes the cards uniformly to the four players. Also,
he / she scores the game points for players.
AbstractPlayer / An abstract player, which consists of common properties of a player.
Player AbstractPlayer A Big 2 player, which inherits the base class AbstractPlayer.
GameController / The Big 2 game controller which controls the game flow.
Member function Description
Card() A constructor that initializes all data members.
~Card() A destructor that destructs all data members if any.
int getValue() Returns the value of the card.
char getSuit() Returns the suit of the card.
void setValue(int v) Sets the value of the card.
void setSuit(char s) Sets the suit of the card
bool isSelected() Indicates whether the card is selected, true refers to selected and false
refers to not selected.
void toggle() Toggles a card, which changes the card from selected to not selected,
and from not selected to selected.
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
6
Hand
Member function Description
Hand() A constructor that initializes all data members.
~Hand() A destructor that destructs all data members if any.
int getNoCard() Returns the number of cards in hand.
bool add(Card^ card) Adds a card to the hand.
Card* release(int v, char s) Returns the card with card value v and suit s.
void clear() Clears all cards from the hand.
Play
Member function Description
Play() A constructor that initializes all data members.
~Play() A destructor that destructs all data members if any.
int getNoCard() Returns the number of cards in the current play.
bool add(Card* card) Adds a card to the play.
bool isValidPlay() Checks the validity of current play. Returns true if the play is valid,
otherwise return false.
Card* release() Returns the array of cards in the current play.
void clear() Clears all cards from play.
Deck
Member function Description
Deck() A constructor that initializes all data members.
~Deck() A destructor that destructs all data members if any.
void createDeck() Create a deck of cards with 52 cards.
(This function should perform something similar to what the constructor
does, but it can be called if needed, other than just the object get constructed
the first time.)
int getNoCard() Returns the number of cards in deck.
void clear() Clears all cards from deck.
Faculty of Science and Technology, UoW College Hong Kong / Community College of City University
AST21105 Object-Oriented Programming & Design
7
Dealer
Member function Description
Dealer() A constructor that initializes all data members.
~Dealer A destructor that destructs all data members if any.
void shuffle() Shuffles cards.
void deal(Hand& hand) Deals one card to a hand.
AbstractPlayer
Member function Description
AbstractPlayer() A constructor that initializes all data members.
~AbstractPlayer() A destructor that destructs all data members if any.
int getPenaltyScore() Returns the penalty score of player.
void addPenaltyScore(int s) Add penalty score to player.
virtual void win()= 0 Checks whether the player wins the game. It is a pure virtual function.
void resetPenaltyScore() Reset the penalty score of player to 0.
Player
Member functions Description
Player() A constructor that initializes all data members.
~Player() A destructor that destructs all data members if any.
virtual void win() Checks whether the player wins the game. This is an overridden function.
GameController
Member functions Description
GameController() A constructor that initializes all data members.
~GameController() A destructor that destructs all data members if any.
void play() Plays a round of Big 2.
Note: You need to add data members to classes for facilitating the implementation of game. Also, extra
member functions could be added to the classes if you think it is useful for your program. However,
you are NOT allowed to remove or change the given functions.
End

bestdaixie

评论已关闭。