public String roll()
Random generate = new Random();
boolean winner = false;
for (int x=1; x<=3; x++)
firstNum = generate.nextInt(6)+1;
secondNum = generate.nextInt(6)+1;
diceRoll = firstNum + secondNum;
System.out.println("Roll number " + x + " was " + diceRoll);
if(userNum == diceRoll)
winner = true;
System.out.println("\nYou win!! Congratulations");
When I run This class on my driver class at the end of the whole loop I get my numbers and all but I also get the word null at the end.
Just like this:
Roll number 1 was 6
Roll number 2 was 8
Roll number 3 was 2
You win!! Congratulations
Where is the println statement that prints out the null?
What is the value of the roll variable that is returned by the roll() method?
Line 34, you are returning roll variable but you didn't have anything to do with the variable inside the method. The method is supposed to build up a String and return it?