Greetings All,
My name is Declan and I am new to both
Java programming, programming in general and of course this site.
I hope to get to know you all in the coming years (!)
My first question is this. I have the following two Enums:
public enum CardSuit { SPADES, CLUBS, DIAMONDS, HEARTS } and
public enum CardRank { DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE }
I create an object (card1) with the following constructor:
public card (
String suit, String rank) {
this.name = name;
this.rank = rank;
}
My question is, how do I compare the card1 object to these Enums?
For example if my object is Card1 (Spades, Six) and I create a
second object (Hearts, Two), I want to have it that because SPADES is first (higher) in the Enum list that object1 (Card1) is automatically higher that object2 (Card2).
I have to write a program that compares the values of
cards.
I have been working with CompareTo() with little success
Any help is greatly appreciated
Thanks in advance
Declan