首先游戏的简介如下:
Blackjack Game
This project is a simplified version of the casino card game Blackjack. The game works like this: Players are dealt cards with point values. Each player tries to reach a total of 21 without exceeding that amount. Numbered cards count as their face value. An ace counts as either 1 or 11 (whichever is best for the player), and any jack, queen, or king counts as 10.
The computer is the house (the casino) and it competes against one to seven players. At the beginning of the round, all participants (including the house) are dealt two cards. Players can see all of their cards, along with their total. However, one of house’s cards is hidden for the time being.
Next, each player gets the chance to take one additional card at a time for as long as he likes. If a player’s total exceeds 21 (known as busting), the player loses. After all players have had the chance to take additional cards, the house reveals its hidden card. The house must then take additional cards as long as its total is 16 or less. If the house busts, all players who have not busted win. Otherwise, each remaining player’s total is compared to the house’s total. If the player’s total is greater than the house’s, he wins. If the player’s total is less than the house’s, he loses. If the two totals are the same, the player ties the house (also known as pushing). Figure 1 shows the game.
其中的一种结果显示:
1.BlackJack类
类 |
基类 |
用途 |
Card |
无 |
一张普通的扑克牌 |
handCard |
无 |
一手牌,Card 对象的集合 |
deckCard |
Hand |
一副牌,具有除了Hand之外的洗牌和发牌的功能 |
commonPlayer |
Hand |
通用的玩家,不是正式玩家,就是电脑和人都能够玩的公共的 |
Player |
commonPlayer |
一个玩家 |
House |
commonPlayer |
电脑玩家,庄家 |
oneGame |
无 |
一个游戏 |
所有的成员函数都是public的,所有的数据成员都是protected的,继承都通过public 继承,即各个派生类都继承基类的所有成员;
2.基本的继承层次图
1.Card是实际的纸牌
2.oneHand是Card的对象,所以有一个数据成员,就是指向Card对象的指针,存在于堆上