Comparing Cards Logic
<p>I am trying to do a crazy 8 card game and I find it very difficult comparing the cards. Take for example, 3 of Diamond should match Jack of Diamond or a Queen of Diamond or a 4 of Diamond et cetera. Can you please help me with the logic in doing this. How do I compare these cards in my Main class? Also, How do I compare the card on the board to the cards in the player hand. For example, the card on the board is 3 of spades and the player has a 2 of spades which can be play on the board card. How do I compare these?
So far, this is what I have written.</p>

<pre><code>public class Card {
protected int suit;
protected int rank;


         protected String[] suits = { "Hearts", "Clubs", "Spades", "Diamonds"};

         protected String[] ranks = {"Ace", "2", "3", "4", "5", "6","7", "8", "9","10", "Jack", "Queen", "King" };

public Card(int rank, int suit){
    this.rank = rank;
    this.suit = suit;


}

public int getSuit() {
    return suit;
}

public void setSuit(int suit) {
    this.suit = suit;
}

public int getRank() {
    return rank;
}

public void setRank(int rank) {
    this.rank = rank;
}
public String toString(){
    return this.ranks[rank] +" of "+ this.suits[suit];
}
</code></pre>

<p>}</p>

<pre><code>  public class Deck {
  private ArrayList&lt;Card&gt; cards; //initialize cards arrayList using the card class

/*
 * Create a deck of cards
 */

public Deck() {
    cards = new ArrayList&lt;&gt;();

    /*
     * Fill the ArrayList with all of the cards to build a deck
     */

    for (int a = 0; a &lt;= 3; a++) {
        for (int b = 0; b &lt;= 12; b++) {
            cards.add(new Card(a, b));
        }
    }
    Collections.shuffle(cards); // shuffle the deck of cards
}

/*
 * Draw card by "removing" it from the filled cards array
 */

public Card drawCard() {return cards.remove(0);}

public int getTotalCards() {return cards.size();}
</code></pre>

<p>}</p>

<pre><code> public class Hand{
ArrayList&lt;Card&gt;handOfPlayer;
String playerName;
public Hand(){

    handOfPlayer = new ArrayList&lt;&gt;();

  }





public ArrayList&lt;Card&gt; getHandOfPlayer() {
    return handOfPlayer;
}

public void setHandOfPlayer(ArrayList&lt;Card&gt; handOfPlayer) {
    this.handOfPlayer = handOfPlayer;
}


//print out he cards in player hand
    public ArrayList&lt;Card&gt;addCard(Card newCard){
    handOfPlayer.add(newCard);
    return handOfPlayer;

}

public void displayHand(){
    for(int i =1; i&lt;handOfPlayer.size(); i++){
        System.out.println(i + ": "+ handOfPlayer.get(i));
    }
}
//Display number of cards in player hand
public void displaySize(){
    System.out.println(handOfPlayer.size());
}

public String getPlayerName() {
    return "Welcome! "+ this.playerName;
}

public void setPlayerName(String playerName) {
    this.playerName = playerName;
}

public Card removeCard(int removeCard){
    Card cardOfCard = handOfPlayer.remove(removeCard);
    return cardOfCard;
}
</code></pre>

<p>}</p>