Sep 25, 2015 04:32 PM
(This post was last modified: Sep 25, 2015 11:53 PM by Bull..)
Code
public class DiceRoller2
{
public static void main(String[] args)
{
int num1;
int num2;
int total;
num1 = (int)(Math.random() * (6+1)-1) + 1;
num2 = (int)(Math.random() * (6+1)-1) + 1;
total = num1 + num2;
System.out.println("The two six sided dice rolled equal: " + total);
//This gets the random number for the dice everything under this point draws the die according to the number rolled.
if(total == 2)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.25,.5,.015);
StdDraw.circle(.75,.5,.015);
}
else if(total == 3)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.30,.5,.015);
StdDraw.circle(.75,.5,.015);
}
else if(total == 4)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.20,.5,.015);
StdDraw.circle(.30,.5,.015);
StdDraw.circle(.70,.5,.015);
StdDraw.circle(.80,.5,.015);
}
else if(total == 5)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.25,.6,.015);
StdDraw.circle(.25,.4,.015);
StdDraw.circle(.25,.5,.015);
StdDraw.circle(.75,.5,.015);
}
else if(total == 6)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.75,.6,.015);
StdDraw.circle(.75,.4,.015);
StdDraw.circle(.75,.5,.015);
StdDraw.circle(.25,.6,.015);
StdDraw.circle(.25,.4,.015);
StdDraw.circle(.25,.5,.015);
}
else if(total == 7)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.20,.55,.015);
StdDraw.circle(.30,.55,.015);
StdDraw.circle(.20,.45,.015);
StdDraw.circle(.30,.45,.015);
StdDraw.circle(.75,.6,.015);
StdDraw.circle(.75,.4,.015);
StdDraw.circle(.75,.5,.015);
}
else if(total == 8)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.20,.55,.015);
StdDraw.circle(.30,.55,.015);
StdDraw.circle(.20,.45,.015);
StdDraw.circle(.30,.45,.015);
StdDraw.circle(.80,.55,.015);
StdDraw.circle(.70,.55,.015);
StdDraw.circle(.80,.45,.015);
StdDraw.circle(.70,.45,.015);
}
else if(total == 9)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.80,.55,.015);
StdDraw.circle(.70,.55,.015);
StdDraw.circle(.80,.45,.015);
StdDraw.circle(.70,.45,.015);
StdDraw.circle(.20,.55,.015);
StdDraw.circle(.30,.55,.015);
StdDraw.circle(.20,.45,.015);
StdDraw.circle(.30,.45,.015);
StdDraw.circle(.25,.5,.015);
}
else if(total == 10)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.20,.55,.015);
StdDraw.circle(.30,.55,.015);
StdDraw.circle(.20,.45,.015);
StdDraw.circle(.30,.45,.015);
StdDraw.circle(.25,.5,.015);
StdDraw.circle(.80,.55,.015);
StdDraw.circle(.70,.55,.015);
StdDraw.circle(.70,.45,.015);
StdDraw.circle(.80,.45,.015);
StdDraw.circle(.75,.5,.015);
}
else if(total == 11)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.80,.55,.015);
StdDraw.circle(.70,.55,.015);
StdDraw.circle(.70,.45,.015);
StdDraw.circle(.80,.45,.015);
StdDraw.circle(.75,.5,.015);
StdDraw.circle(.20,.6,.015);
StdDraw.circle(.20,.4,.015);
StdDraw.circle(.20,.5,.015);
StdDraw.circle(.30,.6,.015);
StdDraw.circle(.30,.4,.015);
StdDraw.circle(.30,.5,.015);
}
else if(total == 12)
{
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.20,.6,.015);
StdDraw.circle(.20,.4,.015);
StdDraw.circle(.20,.5,.015);
StdDraw.circle(.30,.6,.015);
StdDraw.circle(.30,.4,.015);
StdDraw.circle(.30,.5,.015);
StdDraw.square(.25,.5,.15);
StdDraw.square(.75,.5,.15);
StdDraw.circle(.70,.6,.015);
StdDraw.circle(.70,.4,.015);
StdDraw.circle(.70,.5,.015);
StdDraw.circle(.80,.6,.015);
StdDraw.circle(.80,.4,.015);
StdDraw.circle(.80,.5,.015);
}
}
}
