Instead of passing the RedDod object and then ignoring, I suggest you make the method non-static and only set fields of that class.
import java.util.Random;
public class RedDog implements Comparable {
private final Suit suit;
private final Face face;
enum Suit {
CLUB, SPADES, DIAMONDS, HEARTS
}
static final Suit[] SUITS = Suit.values();
enum Face {
ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING
}
static final Face[] FACES = Face.values();
static final Random RAND = new Random();
public RedDog(Suit suit, Face face) {
this.suit = suit;
this.face = face;
}
public static RedDog random() {
return new RedDog(SUITS[RAND.nextInt(SUITS.length)],
FACES[RAND.nextInt(FACES.length)]);
}
public static void main(String[] args) {
RedDog c1 = RedDog.random();
RedDog c2 = RedDog.random();
System.out.println(c1 + " and " + c2 + " equals is " + c1.equals(c2));
}
@Override
public boolean equals(Object o) { // generated by my IDE
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RedDog redDog = (RedDog) o;
if (suit != redDog.suit) return false;
return face == redDog.face;
}
@Override
public int hashCode() { // generated by my IDE
int result = suit != null ? suit.hashCode() : 0;
result = 31 * result + (face != null ? face.hashCode() : 0);
return result;
}
@Override
public String toString() { // generated by my IDE
return "RedDog{" +
"face=" + face +
", suit=" + suit +
'}';
}
@Override
public int compareTo(RedDog r) {
int cmp = suit.compareTo(r.suit);
if (cmp == 0)
cmp = rank.compareTo(r.rank);
return cmp;
}
}
prints
RedDog{face=KING, suit=SPADES} and RedDog{face=QUEEN, suit=DIAMONDS} equals is false