Having problems with black jack card game in java
<p>I posted this earlier and the majority of my questions were answered but I am just having 1 last error in my code. </p>

<p>SO basically I am making a game of black jack in java. I have a card class, a deck class and my main. The problem I am having is in my main. In my deck class I create a deck of 52 cards in an arraylist. I then have a method deal that will take the top card and add it into the hand arraylist which is the cards that are in the users hands. Once the user doesn't want to continue anymore the cards stop being dealt. The very last part of my main takes the values in the hand arraylist and adds them up and compares them to 21 to see if the user went over or not. I realize that I am trying to hold a Card value in the int total but what would I use to hold the values in the arraylist so that I can compare them? Any help/suggestions or advice is appreciated</p>

<p>the error that I'm getting on this code is this: </p>

<pre><code> 1 error found:
File: E:\Documents\Java Files\Assignment 3\CardGameTester.java  [line: 33]
Error: Type mismatch: cannot convert from Card to int
</code></pre>

<p>the part of my main that is in question is this: </p>

<pre><code>int total;

for(int index = 0; index &lt;= hand.size(); index++)
{
  total = hand.get(index);
}

System.out.println("Your total value for you cards are: " + total);

if(total == 21){
  System.out.println("Congrats, you have won for not going over 21");
}
else
  {
    System.out.println("Sorry, you lose for going over 21");
}
</code></pre>

<p>for anyone who is curious here is my Card and Deck classes:</p>

<pre><code>public class Card
{
  private int rankValue, suitValue;
  private String ranks[] = {"Hearts", "Clubs", "Spades", "Diamonds"};
  private String suits[] = {"Ace", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};

  public Card(int rank, int suit)
  {
    rankValue = rank;
    suitValue = suit;
  }

  public String convertToString(int rank){
    return ranks[rank];
  }

  public void setRank(int rank){
    rankValue = rank;
  }

  public void setSuit(int suit){
    suitValue = suit;
  }

  public int getRank(){
    return rankValue;
  }

  public int getSuit(){
    return suitValue;
  }

  public String toString(){
    String name = ranks[rankValue] + " of " + suits[suitValue];
    return name;
  }
}
</code></pre>

<p>Deck class:</p>

<pre><code>import java.util.ArrayList;
import java.util.Collections;

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

  public Deck()
  {
    for(int a = 1; a &lt;= 4; a++)
    {
      for(int b = 1; b &lt;= 13; b++)
      {
        Card c = new Card(a,b);
        cards.add(c);
      }
    }
    shuffle();
  }

  public void shuffle(){
    Collections.shuffle(cards);
  }

  public Card deal(){
    int index = 0;
    Card c = cards.remove(index);
    index++;
    return c;
  }
}
</code></pre>
