title: What is wrong with my testing Player Class in Blackjack Java
body: <p>I am trying to test my player class properly, I have almost done it but I am having issues with my <strong>p1.setPlayerHand</strong> method. This is the following code I have used for my player class:</p>
  
  <p><strong>Player Class:</strong></p>
  
  <pre><code> package model;
  
    public class Player
   {
  private String PlayerName;
  private Hand PlayerHand;
  private boolean Dealer;
  
  public Player(String name)
  {
      PlayerName = name;
      PlayerHand = new Hand();
      Dealer = false;
  }
  
  public void setName (String name)
  {
      this.PlayerName = name;
  }
  
  public String getName()
  {
      return PlayerName;
  }
  
  public void setDealer (Boolean dealer)
  {
      this.Dealer = dealer;
  }
  
  public boolean getDealer()
  {
      return Dealer;
  }
  
  public void setPlayerHand (Hand hand)
  {
      this.PlayerHand = hand;
  }
  
  public void getHand()
  {
      PlayerHand.displayCardsinHand();
  }
  
  public static void main (String [] args)
  {
      Player p1 = new Player("player1");
      Hand h = new Hand();
      //System.out.println(p1);
      p1.setName("BARRY");
  
      System.out.println(p1.getName());
      p1.setDealer(false);
      System.out.println(p1.getDealer());
  
              //this is the error that is preventing my program to run
      p1.setPlayerHand(h.addCard(new Card(Suit.CLUBS, CardRank.ACE)));
      p1.getHand();
  }
    }
  </code></pre>
  
  <p>The following error I receive (after testing the Player Class) is this:</p>
  
  <p><strong>Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method setPlayerHand(Hand) in the type Player is not applicable for the arguments (void)
  at model.Player.main(Player.java:57)</strong> </p>
  
  <p>This is the Hand Class underneath (that is linked to the Player Class):</p>
  
  <p><strong>Hand Class:</strong></p>
  
  <pre><code>package model;
  
  import java.util.Vector;
  import java.util.Random;
  
  public class Hand
  
  {
  private Vector&lt;Card&gt; hand;
  
  public Hand()
  {
      hand = new Vector&lt;Card&gt;();
  }
  
  public void addCard(Card c)
  {
  
      hand.add(c);
  }
  
  public void displayCardsinHand()
  {
      for (int card = 0; card &lt; hand.size(); card++)
      {
              System.out.println(hand.elementAt(card));
      }
  }
  
  public int getCardsinHand()
  {
      return hand.size();
  }
  
    public Card getCard(int position)
    {
      if(position &gt;= 0 &amp;&amp; position &lt; hand.size())
          return (Card)hand.elementAt(position);
      else
          return null;
    } 
  
    public int getScore()
    {
      int value = 0;
      boolean ace = false;
  
      for (int i = 0; i &lt; hand.size(); i++)
      {
          Card c;
          c = getCard(i);
          value = value + c.getRankValue();
  
          if(c.getRankValue() == 1)
          {
              ace = true;
          }
      }
  
      if(ace == true &amp;&amp; value + 10 &lt;= 21)
      {
          value = value + 10;
      }
  
      return value;   
  }
  public static void main (String [] args)
  {
      Hand h = new Hand();
      System.out.println(h);
  
      h.displayCardsinHand();
  
      System.out.println(h.getCardsinHand());
      h.addCard(new Card(Suit.HEARTS, CardRank.ACE));
      System.out.println(h.getCardsinHand());
      h.addCard(new Card(Suit.SPADES, CardRank.JACK));
      System.out.println(h.getCardsinHand());
      h.addCard(new Card(Suit.DIAMONDS, CardRank.QUEEN));
      System.out.println(h.getCardsinHand());
      h.addCard(new Card(Suit.CLUBS, CardRank.KING));
      System.out.println(h.getCardsinHand());
      System.out.println(h.getCardsinHand());
      h.displayCardsinHand();
      h.getCard(1);
  
      System.out.println(h.getScore());
  }
  
    }
  </code></pre>
  
  <p>I have tried modifying the <strong>p1.setPlayerHand</strong> testing numerous times. I appreciate any advice and tips on how to solve this issue, thank you.
  If my code is too long for this post then I will gladly accept any advice on what I should do to cut it short (for future reference).
  If anyone here required to see any other classes that I wrote (that may help them help me solve this error) then please notify me on here, thank you.</p>