title: One 'cannot find value' stands between me and my first game. [code shown]
body: <p>So I'm building a version of Go Fish. I am done with all of the coding, but it won't run because in the Player class, I can't use a Card.rank parameter in methods. I understand that, but I still need to be able to input a rank somehow.</p>
  
  <p>Look at my Card constructor and any instance of me trying to use a Player method where I need a rank input (Player.subSets and Player.searchHand). (I am also only showing one player's turn code to be concise.)</p>
  
  <p>Program (main) class:</p>
  
  <pre><code>import java.util.*;
  
  public class Program
  {
  public static void main(String args[]) 
  {
      String[] rank = {"two", "three", "four", "five", "six", "seven", "eight",
                   "nine", "ten", "jack", "queen", "king", "ace"};
      String[] suit = {"hearts", "diamonds", "spades", "clubs"};
      Scanner scan = new Scanner(System.in);
      String something = "yes", something2 = "yes", success = "yes"; //Use with while loops
      String turn = "one";
      String temp; //Use with setting names
      String temp2, temp3; //For player being searched
      Card temp4 = new Card(); //For player being searched
      Card[] deck = new Card[52]; //Deck array
      int playercount = 0;
      Player one = new Player("temp");
      Player two = new Player("temp");
      Player three = new Player("temp");
      Player four = new Player("temp");
  
      //Start game
      while (something.equalsIgnoreCase("yes"))
      {
          //Prepare game
          Card.makeDeck(deck, rank, suit);
          deck = Card.getDeck();
          Card.shuffle(deck);
  
          while (something2.equalsIgnoreCase("yes") || playercount &lt; 2) //Add players to game
          {
              System.out.println("Would a(nother) player like to join?");
              something2 = scan.nextLine();
              System.out.println();
              if (something2.equalsIgnoreCase("yes"))
              {
                  if (playercount &lt;= 4)
                  {
                      if (playercount == 0)
                      {
                          System.out.println("What is your name: ");
                          Player one1 = new Player(scan.nextLine());
                          one = one1;
                          playercount++;
                          System.out.println();
                      }
                      else if (playercount == 1)
                      {
                          System.out.println("What is your name: ");
                          Player two2 = new Player(scan.nextLine());
                          two = two2;
                          playercount++;
                          System.out.println();
                      }
                      else if (playercount == 2)
                      {
                          System.out.println("What is your name: ");
                          Player three3 = new Player(scan.nextLine());
                          three = three3;
                          playercount++;
                          System.out.println();
                      }
                      else if (playercount == 3)
                      {
                          System.out.println("What is your name: ");
                          Player four4 = new Player(scan.nextLine());
                          four = four4;
                          playercount++;
                          System.out.println();
                      }
                      else {System.out.println("Only four players are allowed.");
                            something2 = "no";}
                  }
              }
              else if (playercount &lt; 2)
              {
                  System.out.println("You need at least two players...");
                  System.out.println();
              }
          }
          //Deal cards
          if (playercount == 2) 
          {
              for (int i = 1; i &lt; 8; i++)
              {
                  one.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  two.addCard(Card.draw(deck));
                  deck = Card.getDeck();
              }
          }
          else if (playercount == 3) 
          {
              for (int i = 1; i &lt; 8; i++) 
              {
                  one.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  two.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  three.addCard(Card.draw(deck));
                  deck = Card.getDeck();
              }
          }
          else
          {
              for (int i = 1; i &lt; 6; i++)
              {
                  one.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  two.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  three.addCard(Card.draw(deck));
                  deck = Card.getDeck();
                  four.addCard(Card.draw(deck));
                  deck = Card.getDeck();
              }
          }
          //Take turns
          while (something.equalsIgnoreCase("yes"));
          {
              success = "yes";
              if (turn.equalsIgnoreCase("one") &amp;&amp; something.equalsIgnoreCase("yes"))
                  {
                      System.out.println("Player one: " + one.getName() + "'s turn!");
                      System.out.println();
                      //Output hand
                      System.out.println("You have: " + Card.toString(one.getHand()));
                      System.out.println();
                      //Ask what who to search
                      System.out.println("Whose hand would you like to check?");
                      System.out.println("(Enter a player's name.)");
                      temp2 = scan.nextLine(); //Set player name to temp2
                      System.out.println();
                      //Ask what to search
                      while (success.equalsIgnoreCase("yes"))
                      {
                          System.out.println("Remember, you have: " + Card.toString(one.getHand()));
                          System.out.println();
                          System.out.println("Would you like to search for a two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, or ace?");
                          temp3 = scan.nextLine(); //Set desired rank to temp3
                          //Check player two
                          if (temp2.equalsIgnoreCase(two.getName()))
                          {
                              if (two.searchHand(two.getHand(), temp3) != null)
                              {
                                  while (two.searchHand(two.getHand(), temp3) != null)
                                  {
                                      one.addCard(two.searchHand(two.getHand(), temp3));
                                      two.subCard(two.searchHand(two.getHand(), temp3));
                                      one.subSets(one.getHand(), temp3);
                                  }
                              }
                              else if (two.searchHand(two.getHand(), temp3) == null)
                              {
                                  System.out.println();
                                  System.out.println("Go fish!");
                                  System.out.println(one.getName() + " drew a card.");
                                  System.out.println();
                                  one.addCard(Card.draw(deck));
                                  one.subSets(one.getHand(), temp3);
                                  deck = Card.getDeck();
                                  turn = "two";
                                  success = "no";
                                  something = one.checkWin();
                                  if (something.equalsIgnoreCase("no"))
                                      System.out.println(one.getName() + " won!");
                              }
                          }
                          //Check player three
                          if (temp2.equalsIgnoreCase(three.getName()))
                          {
                              if (three.searchHand(three.getHand(), temp3) != null)
                              {
                                  while (three.searchHand(three.getHand(), temp3) != null)
                                  {
                                      one.addCard(three.searchHand(three.getHand(), temp3));
                                      three.subCard(three.searchHand(three.getHand(), temp3));
                                      one.subSets(one.getHand(), temp3);
                                  }
                              }
                              else if (three.searchHand(three.getHand(), temp3) == null)
                              {
                                  System.out.println();
                                  System.out.println("Go fish!");
                                  System.out.println(one.getName() + " drew a card.");
                                  System.out.println();
                                  one.addCard(Card.draw(deck));
                                  one.subSets(one.getHand(), temp3);
                                  deck = Card.getDeck();
                                  turn = "two";
                                  success = "no";
                                  something = one.checkWin();
                                  if (something.equalsIgnoreCase("no"))
                                      System.out.println(one.getName() + " won!");
                              }
                          }
                          //Check player four
                          if (temp2.equalsIgnoreCase(four.getName()))
                          {
                              if (four.searchHand(four.getHand(), temp3) != null)
                              {
                                  while (four.searchHand(four.getHand(), temp3) != null)
                                  {
                                      one.addCard(four.searchHand(four.getHand(), temp3));
                                      four.subCard(four.searchHand(four.getHand(), temp3));
                                      one.subSets(one.getHand(), temp3);
                                  }
                              }
                              else if (four.searchHand(four.getHand(), temp3) == null)
                              {
                                  System.out.println();
                                  System.out.println("Go fish!");
                                  System.out.println(one.getName() + " drew a card.");
                                  System.out.println();
                                  one.addCard(Card.draw(deck));
                                  one.subSets(one.getHand(), temp3);
                                  deck = Card.getDeck();
                                  turn = "two";
                                  success = "no";
                                  something = one.checkWin();
                                  if (something.equalsIgnoreCase("no"))
                                      System.out.println(one.getName() + " won!");
                              }
                          }
                      }
                  }
             //ALL THE CODE FOR OTHER TURNS HERE
          }
          //Replay
          System.out.println("Would you like to play again?");
          something = scan.nextLine();
      }
  }
  
  }
  </code></pre>
  
  <p>Player class:</p>
  
  <pre><code>import java.util.*;
  
  public class Player
  {
  private static String name;
  private static Card[] hand = new Card[52];
  private static Card[] sets = new Card[52];
  private static int handsize = 0, nullcount = 0;
  private static String win = "no"; 
  private static int temp = 1; //For subCard
  private static int temp2 = 0, temp3 = 0; //For subSets
  
  //Constructor
  public Player(String n)
  {
      name = n;
  }
  
  //Mutators
  //Add new card to hand
  public static void addCard(Card c)
  {
      hand[handsize] = c;
      handsize++;
  }
  //Lose card that was searched for
  public static void subCard(Card c)
  {
      for (int i = 0; i &lt; hand.length; i++)
      {
          if (c == hand[i])
          {
              temp = i;
              if (temp &lt; 51)
                  temp++;
               hand[i] = hand[temp];
          }
      }
      hand[(hand.length - 1)] = null;
      handsize--;
  }
  //Lose sets of cards
  public static void subSets(Card[] h, Card.rank r)
  {
      //See if there are four of a kind
      for (int i = 0; i &lt; h.length; i++)
      {
          if (h[i].rank == r)
          {
              temp2++;
          }
      }
      //Drop set of four
      if (temp2 == 4)
      {
          for (int i = 0; i &lt; h.length; i++)
          {
              if (h[i].rank == r)
                  h[i] = null;
              for (int ii = (i + 1); ii &lt; (h.length - 1); ii++)
              {
                  temp3 = i;
                  h[temp3] = h[ii];
                  temp3++;
              }
              h[(h.length - 1)] = null;
          }
      }
      hand = h;
  }
  
  //Accessors
  public static String getName()
  {
      return name;   
  }
  public Card[] getHand()
  {
      return hand;   
  }
  public Card searchHand(Card[] h, Card.rank r)
  {
      for (int i = 0; i &lt; h.length; i++)
      {
          if (h[i].rank == r)
              return h[i];
          else if (i == h.length - 1)
              return null;
      }
  }
  public String checkWin()
  {
      for (int i = 0; i &lt; hand.length; i++)
      {
          if (hand[i] == null)
              nullcount++;
      }
      if (nullcount == (hand.length - 1))
          return "no"; //Set equal to something in Program
      else
      {
          nullcount = 0;
          return "yes"; //Set equal to something in Program
      }
  }
  }
  </code></pre>
  
  <p>Card class:</p>
  
  <pre><code>import java.util.*;
  
  public class Card
  {   
  public String suit;
  public String rank;
  private static int temp = 0, temp2 = 0; //Use for reseting rank and suit
  private static Card temp3; //Use for draw method
  private static int temp4 = 1; //Use for draw and shuffle, always back to 1
  private static Card[] deck = new Card[52];
  private static Random random = new Random();
  
  //Constructors
  public Card()
  {
      this.rank = "two";
      this.suit = "hearts";
  }
  public Card(String r, String s)
  {
      this.rank = r;
      this.suit = s;
  }
  
  //Mutators
  //Make deck
  public static void makeDeck(Card[] c, String[] r, String[] s)
  {
      for (int i = 0; i &lt; c.length; i++)
      {
          c[i] = new Card(r[temp], s[temp2]);
          temp++; temp2++;
          //Reset rank and suit
          if (temp &gt; 12)
              temp = 0;
          if (temp2 &gt; 3)
              temp2 = 0;
      }
      deck = c;
  }
  
  //Accessors
  //Return deck
  public static Card[] getDeck()
  {
      return deck;   
  }
  //Shuffle
  public static Card[] shuffle(Card[] c) 
  {
      for (int i = 0; i &lt; c.length; i++)
      {
          int rand = (int)(random.nextInt(52)*(i + 1));
          //Don't let anything be in a slot that doesn't exist
          while (rand &gt; c.length)
          {
              temp4 = random.nextInt(52);
              rand -= temp4;
          }
          if (rand &lt; 0)
          {
              rand += temp4;
              Card temp = c[i];
              c[i] = c[rand];
              c[rand] = temp;
          }
      }
      deck = c;
      temp4 = 1;
      return deck;  
  }
  //Draw
  public static Card draw(Card[] c)
  {
      temp3 = c[0];
      for (int i = 0; i &lt; c.length - 1; i++)
      {
          c[i] = c[temp4];
          if (temp4 &lt; 51)
              temp4++;
      }
      c[(c.length - 1)] = null;
      temp4 = 1;
      deck = c;
      return temp3;
  }
  //Return string
  public static String toString(Card[] h) 
  {
      String temp5 = "yes";
      while (temp5.equals("yes"))
      {
          for (int i; i &lt; h.length; i++)
          {
              if (h[i] != null)
                  return h[i].rank + " of " + h[i].suit +", ";
              else temp5 = "no";
          }
      }
  }
  }
  </code></pre>