title: Transferring variables from class to class in Java
body: <p>I have been having some issues transferring Variable data from Class to Class in Java whilst completing a Monopoly-type text-based game.</p>
  
  <p>I have been trying to transfer the roll1 and roll2 variables from the Dice class into the Board Class, but for some reason the data is not being transferred properly, and when I return the combined data from the 2 Rollin the Board class, it just comes back as 0.</p>
  
  <p>Here are my classes:</p>
  
  <pre><code>public class Dice {
  
      static int dots, roll1, roll2, flag;
      Random number = new Random();
  
      public Dice(){
           dots = number.nextInt(6)+1 ;
      }
  
      public void roll1(){
          roll1 = number.nextInt(dots)+1;
      }
  
      public void roll2(){
          roll2 = number.nextInt(dots)+1;
      }
  
      public int getDots1(){
          return roll1;
      }
  
      public int getDots2(){
          return roll2;
      }
  
      public String getSame(){
          if(roll1 == roll2){
              flag++;
              return("Your rolls were the same");
          }
          else{
              return(" ");
          }
  
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class Board {
      static int roll1 = Dice.roll1;
      static int roll2 = Dice.roll2;
      public static int i;
      public int Turn = 0;
      public int totalP = 0;
      public static int Pos = 0;
      public static int[] Players= {1, 2, 3, 4};
      public static int[] Square = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
      public static int Money = 40000;
      static ArrayList&lt;Integer&gt; pPos = new ArrayList&lt;Integer&gt;();
      void pPosList(){}
  
      public Board(int totalP){
          this.totalP = totalP;
      }
  
      public static int getPos(){
             while(Money != 0){
             for(i=0;i&lt;Players.length;i++){ 
                 System.out.println("Player Turn: Player "+(i));
                 Pos = Square[roll1 + roll2];
                 pPos.set(0, Pos);
                 return roll1;
             }
          }
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class Blobfish {
  
      public void main(String[] args) {
          System.out.println(" " +Board.getPos());
          Dice dice = new Dice();
          dice.roll1();
          dice.roll2();
          System.out.println("First Roll: " +dice.getDots1());
          System.out.println("Second Roll: " +dice.getDots2());
          System.out.println("" + dice.getSame());
          System.out.println("Your Current Position = " +Board.getPos());
      } 
  }
  </code></pre>