I'm Currently making a small dice game.
It's for homework purposes and I'm not really stuck, just wondering if there is an easier way to do it.
I've created a roll() method to return a Random 1-6 number:
//Dice method to create new Random numbers
public int roll()
{
int diceThrow = (int)(6*Math.random() + 1); // Range 1-6
return diceThrow;
}
Now when a player throws 1-5 He will receive 10 points and with 3 6's he'll get 100 points.
I've created the 3 6's as following:
if(dice1 == 6 && dice2 == 6 && dice3 == 6)
{
//Give 100 points to user
}
I can do it the same way for 1-5 but is there an easier way, to equal 3 integers at once?
Edited by SterAllures, 18 October 2011 - 02:37 AM.
Problem Solved


Sign In
Create Account


Back to top









