有人能帮帮我吗?我真的卡住试图使方法changeCard工作,我尝试的一切都不起作用。其他一切工作正常我假设它与myDeck.shuffleDeck或myDeck.getSuit和myDeck.getCard有关,它打破我的整个游戏,因为玩家无法切换他的卡。
这是我的cardClass代码
import java.util.Random;
public class Card
{
// instance variables
public DeckOfCards myDeck;
public int card;
public int suit;
public String cardName;
public String getSuitName;
public Card()
{
myDeck = new DeckOfCards();
myDeck.shuffleDeck();
card = myDeck.getCard();
suit = myDeck.getSuit();
setCardName();
}
public String showCard()
{
return cardName;
}
public void changeCard()
{
}
public void setCardName()
{
switch(card)
{
case 0:
cardName = "The Ace of " + getSuitName();
break;
case 10:
cardName = "The Jack of " + getSuitName();
break;
case 11:
cardName = "The Queen of " + getSuitName();
break;
case 12:
cardName = "The King of " + getSuitName();
break;
default:
cardName = "The " + card + " Of " + getSuitName();
}
}
public String getSuitName()
{
switch(suit)
{
case 0 :
return getSuitName = "Spades";
case 1 :
return getSuitName = "Hearts";
case 2 :
return getSuitName = "Diamonds";
case 3 :
return getSuitName = "Clubs";
default:
return "";
}
}
}