我最近決定開始爲我的卡套裝使用枚舉,但似乎無法解決這個錯誤,無論我如何輸入代碼。爲什麼我得到一個SPADE不能解決類型錯誤?
編輯:
/**
*
* A basic constructor class that build the card object.
* The card object will contain value for both the Suit and
* card's Value.
*
*
*
*/
public class Card {
public Enum SUIT{SPADE, CLUB, DIAMOND, HEART};
// This will identify the card suit.
public Enum suit;
//This will hold the card value.
//Jack = 11 ... Ace = 14
public int value;
public Card(Enum suit, int value){
this.suit = suit;
this.value = value;
}
}
我有擡頭的各種答案的網站上,並通過對Orcacle官方的Java文檔的樣子。有人能幫我解決這個問題嗎?
更新:
/**
* *一個基本的構造類,建立卡對象。 *卡對象將包含西裝和卡的價值。 * * * */ 公共類卡{
public enum Suit{SPADE, CLUB, DIAMOND, HEART};
// This will identify the card suit.
private final Suit suit;
//This will hold the card value.
//Jack = 11 ... Ace = 14
private final int value;
public Card(Suit suit, int value){
this.suit = suit;
this.value = value;
}
}
這裏的錯誤截圖: A screenshot of the error
請不要在答案的基礎上改變你的問題。如果他們推薦已經存在於問題中的東西,就很難理解答案。如果需要,請在下面的問題中添加更新。 –
你目前擁有的代碼不會給你一個像「SPADE無法解析爲某種類型」的錯誤。請在出現此錯誤的位置添加代碼。 –
對不起,對於這個,但還沒有學習。添加了錯誤並恢復原始代碼並添加了更新。 –