Need Help With My Game

So I’m making a card game with Java, and here’s the issue I’m running into:
I have an object Card with these variables:

    private int maxHealth;
    private int currentHealth;
    private int cardDamage;
    private String cardName;

Now I have another object type CardSet that holds an array of Cards (Card).
Calling a method called compareCard, and passing in an index of a card and card to compare it to, I’m receiving the wrong output:

public boolean compareCardTo(int index, Card compareMe) {
        return (cardRow[index] == compareMe);

Now, I realized that I can’t compare two objects with ==, so I wanted to ask the forum: which of these options should I do?

  • .equals()

  • (cardrow[index].getHealth() == compareMe) && (and compare all of both card’s variables)
    *or is there another/easier way to compare two card objects?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.