I have the following code at the end of my main class to initialize objects and start the program:
HumanPlayer humanPlayer = new HumanPlayer(baseHold);
Controller controller = new Controller(new ComputerPlayer(), humanPlayer, new Dice(seed));
controller.start();
Inside my Controller class, is the following code:
public class Controller
{
int roller;
public Controller(ComputerPlayer cpuPlayer, HumanPlayer userPlayer, Dice dice)
{
}
//....
}
I am unsure what to initialize above, as I've tried a few things already and it still does not find my object dice in the following code:
public void start()
{
for (int count = 0; count < 5; count++)
{
roller = dice.roll();
System.out.println("Die roll: " + roller);
}
}
roll is a method within the Dice class. Is there a particular way for me to tell it to look for dice as an object within my controller object instead of a variable within my controller object, or am I going about this completely wrong?
I want to be able to roll the die 5 times here.
error:
Controller.java:39: error: cannot find symbol
roller = dice.roll();
^
symbol: variable dice
location: class Controller
1 error
humanPlayerandnew Dice(seed)when you create an instance ofController.