{close} 不能使用对象。原因:没有地方存放播放器

{close} CAN't use the Object. Reason: haven't had a place to store the player

我做了第一部分,但播放器无法使用第二部分 因为我忘记创建一个数组来存储它:

Player[] player = new Player[11];//solution add a array to store the player

for(int i=1;i<=10;i++) {
boolean finishplayeri = false;
Player playeri = new  Player("player"+i); //if you don't create a array to store your player
player[i] = playeri;
}

第二部分:

for(int i=1;i<=noofplayer;i++) { 
player[i].addCard(theDeck.NextCard());  // in here your player[i] will be error
player[i].addCard(theDeck.NextCard());          
player[i].printHand(false);
}

问题:无法使用对象。 原因:没有地方存放您的播放器。 方法:创建一个数组来存储我的播放器。

您必须将您的播放器放入容器中才能处理它。您不会将播放器存放在任何地方。