title: How do I transfer a local variable between two classes?
body: <p>I am writing a noughts and crosses code that can take console arguments to decide which strategy to use (different AI classes). If the user selects 'ultimatecomputerplayer' then this is implemented as p1/p2 depending in which order they input this and the other strategy (could be 'humanplayer' etc.)
  My problem is that the ultimate class needs to know which symbol it is, at the moment the game running class just assigns p1 to X and p2 to O but my ultimate class is written assuming it is X so this poses an issue.</p>
  
  <p>This is the code that assigns the strategies and symbols:</p>
  
  <pre><code>NCGridV3 theGrid = new NCGridV3(gridSize, gridSize);
  GameRunnerV3 theGame = new GameRunnerV3();
  Scanner sc = new Scanner(System.in);
  
  ArrayList &lt;NCPlayer&gt; ret = new ArrayList &lt;NCPlayer&gt;();
  
  for (int i = 1; i &lt; args.length; i++)
  {
      switch (args[i])
      {
          case "RandomComputerPlayer":
              ret.add(new RandomComputerPlayer());
              break;
  
          case "SimpleComputerPlayer":
              ret.add(new SimpleComputerPlayer());
              break;
  
          case "UltimateComputerPlayer":
              ret.add(new UltimateComputerPlayer());
              break;
  
          case "HumanPlayer":
              ret.add(new HumanPlayer(sc, theGame));
              break;      
      }
  }
  
  NCPlayer p1 = ret.get(0);
  NCPlayer p2 = ret.get(1);
  
  p1.setMySymbol(SquareStatus.CROSS);
  p2.setMySymbol(SquareStatus.NOUGHT);
  </code></pre>
  
  <p>I tried to assign the strategy's symbol like so:</p>
  
  <pre><code>public class UltimateComputerPlayer  extends GenericPlayer implements NCPlayer 
  {       
      public UltimateComputerPlayer()
      {
          super();
      }
  
      @Override
      public GridCoordinate getNextMove(NCGridV3 currentGrid) 
      {
          SquareStatus symbol = GenericPlayer.getMySymbol();
  </code></pre>
  
  <p>But eclipse tells me I cant make a static reference to a non-static method. </p>
  
  <p>Another option I tried was passing an integer into the UltimateComputer Class which would be 'i' from the loop in the game runner class, then having the symbol assign dependent on which place the class was called like so:</p>
  
  <pre><code>public UltimateComputerPlayer()
      {
          super();
  
          SquareStatus mysymbol;
          if (NC == 1)
              mysymbol = NCGridV3.SquareStatus.CROSS;
          if (NC == 2)
              mysymbol = NCGridV3.SquareStatus.NOUGHT;
      }
  
      @Override
      public GridCoordinate getNextMove(NCGridV3 currentGrid) 
      {
      .......
  </code></pre>
  
  <p>But this variable is not assigned in the GridCoordinate class and I dont know how to make it.</p>
  
  <p>Any help is greatly appreciated, Thanks.</p>