看了 加我qq通知 立马给分
大家好:
您们看一下这个就是关于21点的游戏;
谁给我解决了100分立即给:
看Decks的例子;
public Decks(int numDecks)
{
generator = new Random();
tracing = true;
cards = new String[numDecks][NUM_CARDS * NUM_SUITS];
for (int deck=0; deck<numDecks; deck++)
{
for (int suit=0; suit<NUM_SUITS; suit++)
{
for (int card=0; card<NUM_CARDS; card++)
{
cards[deck][(suit*NUM_CARDS)+card]=CARD_FACES[card]+ " of " + SUITS[suit];
}
}
}
}
playersCards=new int[HAND_SIZE];
computersCards=new int[HAND_SIZE];
}
这段话int numDecks 我的理解是传入几就创建几付牌
public void drawCard(boolean playersTurn)
{
int deck;
int card;
int result;
boolean duplicate;
trace("drawCard: begins");
do
{
//确定要下一张牌
deck=generator.nextInt(cards.length);
card=generator.nextInt(NUM_CARDS*NUM_SUITS);
result=deck*NUM_CARDS+card;
//检查是否已经发牌
duplicate=false;
for (int i=0; i<HAND_SIZE; i++)
{
if ((playersCards[i]==result) || (computersCards[i]==result))
{
duplicate=true;
}
}
}
while (duplicate);
//更新玩家/电脑手中的纸牌
if (playersTurn)
{
playersCards[numPlayersCards]=result;
numPlayersCards++;
totalPlayersCards+=CARD_VALUES[card%NUM_CARDS];
}
else
{
computersCards[numComputersCards]=result;
numComputersCards++;
totalComputersCards+=CARD_VALUES[card%NUM_CARDS];
}
currentCard=result;
trace("drawCard: ends");
}
这里的 deck=generator.nextInt(cards.length);
card=generator.nextInt(NUM_CARDS*NUM_SUITS);
result=deck*NUM_CARDS+card; 这个这么讲为什么这么做呢?
谁能帮我看看 加我qq在线;然后给分;
PlayBackjack07.java:这是驱动程序(有一个main函数),代码已完成,不能更改--他声明,实例化对象 Blackjack class
Decks.java:程序可能会用到,不能更改
Blackjack.java:要完成的程序,类中没有main函数,包含了组织游戏的方法.
注 :Decks class中有的代码不允许再重新在Blackjack.java自己写
玩游戏-玩家被提示 hit/stand 直到游戏结束(won赢/lost输/drawn平局)
电脑爆,(玩家赢)
玩家爆,(玩家输)
分数一样,(平局)
玩家有5张牌,但点数是21或21以下(玩家赢)
玩家点数21或以下,且比电脑高(玩家赢)
电脑点数21或以下,且比玩家高(玩家输)
游戏开始前,玩家会被问到是否想玩游戏(whether or not they want to play),如果不是(no),游戏终止
并且每轮结束,玩家都会被问是否想继续
当玩家不想玩时,以下信息显示:
玩了多少局游戏 How many games were played
玩家赢了几局 How many games were won by the user
玩家输了几局 How many games were lost by the user
平了几局 How many games were drawn.
设计,建立一个GUI用来输出程序(每一轮后显示信息,最后的信息,可能用图解法表示牌),输入(包括提示玩家的信息)
做一个用户交互界面,所有的用户和程序之间的互动都在界面上进行
不用写打开,定位,排列或关闭GUI的程序
例子(没有界面):
Blackjack – A Game of 21
The object of the game is to get as close to 21 as possible or to have 5
cards with a total under 21
The computer continues to draw cards if under 16
Would you like to play Blackjack? y
Player has a Ace of Spades and a 5 of Hearts for a total of 16
Dealer has a 10 of Spades and a ???
Player’s turn...
Hit of Stand?
S
Player sits on 16
Computer’s turn...
Computer has a 7 of Clubs and a 10 of Spades for a total of 17
Computer sits on 17
You LOST!
Would you like to play Blackjack again? y
Player has 3 of Spades and a 7 of Hearts for a total of 10
Dealer has a 4 of Hearts and a ???
Player’s turn...
Hit or Stand?
h
Player draws a Jack of Hearts for a total of 20
Hit or Stand?