誰????こんにちは、私のブラック ジャック ゲームでは、最初にプレーヤーにダブル ダウンを要求することでスプリットを実装し、プレーヤーが拒否した場合はスプリットを許可します。
while(true){
for(int j=0;j<2;j++){
if(players[i].splits[j].getStatus() != true){ // splits is an array of two players hand 1 and hand 2
System.out.print("Choose your next move, " + players[i].name + ", Hand "+ players[i].splits[j].number + ": \n" + "Points: " + players[i].splits[j].points + "\n" + "Hint: ");
getHints(players[i].splits[j]);
System.out.print( "\n1)Hit\n2)Stand\n");
System.out.println();
x2 = IO.readInt();
if (x2==2){
players[i].splits[j].standed = true; // if player stand...
break;
}else if(x2 == 1){//else deal a card
Card c = dealCard(deck);
updatePoints(players[i].splits[j], c);
addCard(players[i].splits[j], c);
System.out.println(players[i].name + ", Hand "+ players[i].splits[j].number + " was dealt: " + c.showCardValue() + " of " + c.showCardSuit() );
boolean isBusted = testPoints(players[i].splits, j); // test for busted
if (isBusted == true){
System.out.println("BUSTED!!!!!!!!!");
players[i].splits[j].busted = true;
break;
}
}
}
System.out.println(players[i].name + ", Hand " + players[i].splits[j].number + " Points: "+ players[i].splits[j].points);
// printStats(players[i].splits[j]);
}
//check to end loop if split is busted to stands...
}
プレーヤーの統計を印刷すると、テキストではなくメモリの場所が表示されます。誰か助けてください。ありがとうございます。さらに情報が必要な場合は、その旨をお知らせください。更新できます。
=======
出力: 3 はプレイヤーの名前です... 10 は配られたカードで、スプリットでした...
Choose your next move, 3, Hand 1:
Points: 10
Hint: You have a 0% chance of busting
1)Hit
2)Stand
1
3, Hand 1 was dealt: Ten of Spades
3, Hand 1 Points: 20
Choose your next move, 3, Hand 2:
Points: 10
Hint: You have a 0% chance of busting
1)Hit
2)Stand
1
3, Hand 2 was dealt: Five of Diamonds
3, Hand 2 Points: 15
Choose your next move, 3, Hand 1:
Points: 20
Hint: You have a 92% chance of busting
1)Hit
2)Stand
2
3, Hand 1 Points: 20
Choose your next move, 3, Hand 2:
Points: 15
Hint: You have a 58% chance of busting
1)Hit
2)Stand
2
3, Hand 1 : Points splitPlayer@1a758cb
Previous Cards dealt:
Ten of Spades
Five of Diamonds
splitPlayer クラス:
public class splitPlayer {
public int points = 0;
boolean busted = false;
boolean standed = false;
int number = 0;
int ace = 0;
String name = "";
Card[] cardsDealt = new Card[12];
public splitPlayer(int number, int points){
this.number = number;
this.name = "Hand "+ number;
this.points = points;
}
public boolean getStatus(){
if(busted == true || standed == true ){
return true;
}else{
return false;
}
}
public void setPoints(int points){
this.points += points;
}
}
=========
更新ポイント:
public static void updatePoints(splitPlayer player, Card c){
int point = c.getValue();
if (point == 1){
player.ace += 1;
player.setPoints(11);
}else{
player.setPoints(point);
}
if (player.points > 21 && player.ace > 0) {
player.points -= 10;
player.ace --;
}
return;
}