If with Pictures, plus a loop
1) Change the makeDice method to handle dice values of 2 - 6. Show each dice value.
2) In your main method, create a random number between 1 and 6 and show that dice value .
3) In your main method, repeat the random number creation 5 times, spreading the dice across the page. Use a loop.
4) In your main method, calculate and show the total of the dice at the bottom of the dice. Use the makeText method which takes in a String to create a world image.
5) Add scanner to get the number of dice from the user.
import javalib.worldimages.*;
import java.awt.Color;
public class Game{
public static void main()
{
WorldImage myGame = AImage.makeRectangle(1000,1000);
myGame = myGame.place(makeDice(1),40,40);
myGame = myGame.place(makeDice(1),140,40);
myGame.show();
}
public static WorldImage makeDice(int number){
int intLength = 60;
WorldImage die = AImage.makeRectangle(intLength,intLength,Color.RED,Mode.filled);
WorldImage dot = AImage.makeCircle(4,Color.BLACK,Mode.filled);
if (number == 1)
{
die = die.place(dot,intLength/2,intLength/2);
}
return die;
}
}