我正在設計一個多人撲克遊戲。我有Human和Computer對象,它們都實現了一個Player接口,其中包含撲克玩家必需的方法。我有一個遊戲中的玩家的ArrayList,我需要去找每個玩家,並檢查他們是否想摺疊手或站立。如果每個人都摺疊了,那麼最後一個查看他們玩法的人會自動獲勝。對於每手牌,首發球員需要旋轉。首先,ArrayList的索引0中的人將首先進入。第二手,索引1中的人會先走。只是想反彈想法,聽取人們對如何實現這些功能的看法。如何旋轉起始玩家?
最初我有這樣的想法,
public void poker(ArrayList<Player> players){
int foldCounter = 0;
int starter = 0;
while (weWantToPlay){
for (int j = starter; j < players.size(); j++){
//get the players game plan
players.get(j).getStand
//the player is folding
if (!player.stand()){
foldCounter++;
//doStuff
else{
//doStuff
}
}
//do more stuff and play poker
//increment starter so the next hand, the second person starts
// this obviously will not work, cause we need go to the end of the list, then wrap around
starter++;
//check who's folded to see if we automatically have a winner
if (foldCounter == players.size()-1){
for (Player element:players){
if (element.stand()){
winner = element;
break;
}
}
}
}
}
您的具體問題是什麼?如果你是在一般的架構討論之後,[programmers.stackexchange](http://programmers.stackexchange.com/faq)可能是一個更好的問題。 – simont 2013-04-10 04:39:32
對不起,看起來我忘了指明我在這裏要求的是什麼。無論如何,我只是在尋找關於如何旋轉開始每場比賽的球員的不同想法。 – 2013-04-10 04:42:51