I am a beginner Java student. Therefore, any help would be greatly appreciated!
I developed the Cards class and Class Deck, which I will use in the game I created. So far, my game seems to work very well, but I have a problem in my card class. I would like to use my getRank () method as a way of accumulating points for cards that a player has (regardless of their correspondence).
For example, if they draw 2 diamonds, it will cost 2 points, 3 hearts 3 points ... ect. I created String[]under the name ranksto try to do this, and I think he does it. However, I would like all face cards (for example, king, queen ...) to have a value of 10. But not all of these cards are at index 10 in my array. Can I get some recommendations on how to do this?
Thanks in advance.
int rank;
int suit;
String[]ranks = { " "," ", " " }
String[]suits = { " ", " ", " "}
public Card(int rank, int suit){
this.rank = rank;
this.suit = suit;
}
public void setRank(int rank){
this.rank = rank;
}
public int getRank(){
return rank;
}
public String toString(){
return ranks[rank]+" of "+suits[suit];
}
source
share