我已經創建了一個Java撲克程序,並且我已經可以檢查玩家或經銷商是否有一對並且如果他們確實獲勝,他們的帳戶餘額。我現在想要得到它,這樣如果一個球員有一個皇家同花順,該計劃將讀取它,並把獎金進入贏家帳戶。我想要使用循環。這是我的代碼到目前爲止創建頭部檢查器的Java撲克遊戲
private int flush(List<PokerCard> hand)
{
List<PokerCard> handToSort = new ArrayList<PokerCard>();
Collections.copy(handToSort, hand);
Collections.sort(handToSort, new CardComparator());
{
List<PokerCard> deck = new ArrayList<PokerCard>();
for (int i = 0; i < 4; i ++)
{
for (int j = 8; j < 13; j ++)
{
System.out.println("You have a Royal Flush 10 through Ace!!");
return flush;
}
else (int j = 0; j < 6; j++)
{
System.out.println("You have a straigth 2 through 6!!");
return flush;
}
else (int j = 1; j < 7; j++)
{
System.out.println("You have a straigth 3 through 7!!");
return flush;
}
else (int j = 2; j < 8; j ++)
{
System.out.println("You have a straigth 4 through 8!!");
return flush;
}
else (int j = 3; j < 9; j++)
{
System.out.println("You have a straigth 5 through 9!!");
return flush;
}
else (int j = 4; j < 10; j++)
{
System.out.println("You have a straigth 6 through 10!!");
return flush;
}
else (int j = 5; j < 11; j++)
{
System.out.println("You have a straigth 7 through Jack!!");
return flush;
}
else (int j =6; j < 12; j++)
{
System.out.println("You have a straigth 8 through Queen!!");
return flush;
}
else (int j = 7; j < 13; j ++)
{
System.out.println("You have a straigth 9 through King!!");
return flush;
}
它顯示爲此代碼的錯誤,但我看不出是什麼錯誤。我對編碼相當陌生,並且給自己設定了一個挑戰,但是我的咬合力超過了我的能力。
你正在混合一個for循環和一個if-else語句,從而產生了一些不正常的'for-else'構造。 Javac不喜歡那樣。我建議大量的基本教程(以及驅魔)。 – Kayaman 2015-03-02 14:09:49