0

My int dice in MovePath() method needs to get the value of int step in GetRollDice() method.

I'm using Java.

How should I do that?

public static int getRollDice(){
   int[] diceStep= {-2,-1,1,2,3};            
   int randomStep = new Random().nextInt(diceStep.length); 
   int step = diceStep[randomStep];
   return step;
}

public static int MovePath(Integer dice,Integer path){
  // int dice = step value from GetRollDice      
  //Get Initial Path
  //Next path = roll dice value + initial path


    return path;

}
dkg
  • 1,775
  • 14
  • 34
Jesse
  • 65
  • 1
  • 17

1 Answers1

1

You just have to call your method, no need to redeclare dice :

public static int MovePath(Integer dice,Integer path){
    dice = getRollDice();     
    //Get Initial Path
    //Next path = roll dice value + initial path

    return path;
}

Keep in mind that everything in Java is a reference to an Object... everything but primitive types like int, short, etc...

See What is the difference between Integer and int in Java? for more information about this.

Community
  • 1
  • 1
dkg
  • 1,775
  • 14
  • 34