I’ve learned Java for 1 month. This time, I’d like to create a poker game. There are two questions about my program. I hope somebody can help me to fix it.
What you should be considering for this sort of classification is Enums:
public enum Suit {
Hearts, Spades, Diamonds, Clubs;
}
public enum Card {
A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K;
}
This benefits your situation since enums can be assigned value easily, to whatever you like, and then they can be compared based on this value. In fact, the Java documentation provides a card game for the introduction to enums.