-1
我的問題是,這是健全的邏輯,但執行不正確(提交服務器將不會採取它)。所以我試圖檢查我的5張牌是否有連續的順序(即2,3,4,5,6等數字),然後如果第五張牌是我希望它評估爲的王牌價值10所以它會像6 7 8 9 A(A爲1卡值),這是我當前的代碼直接在java撲克遊戲
public static boolean hasStraight(Card [] cards) {
boolean isTrue = false;
for(int atPos =0; atPos<cards.length-1; atPos++){
Card ogCard = cards[atPos];
Card notOgCard = cards[atPos+1];
if (ogCard.getValue() == (notOgCard.getValue()-1)){
if ((cards[3]).getValue()==9){
if (cards[4].getValue() ==1);
isTrue = true; //accounting for ace in last position
}
else if(ogCard.getValue() == (notOgCard.getValue()-1)){
isTrue = true; //accounting for ace not in first position
}
}
}
return isTrue;
}
這是我至今不知道接下來會發生什麼。
是'cards'始終堅持「價值牌」排序? – Spotted
是的,您必須先按排名排序。然後檢查23456 ... 10JQKA(簡單案例),然後對2345A進行特殊檢查,這也是筆直的。你在哪裏得到了A是10的想法超出了我。 –