Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a)
- import java.util.Random;
- public class Die {
- private static int sides;
- public static int Generator(int sides)
- {
- sides = 6;
- Random dice = new Random();
- return 1 + dice.nextInt(sides);
- }
- }
- -----------------------------------------------------------------------------------------------------------------------------------
- B)
- public class DieTester {
- public static void main(String[] args) {
- int n = 0;
- final int tries = 10;
- for(int i = 1; i <= tries; i++)
- {
- n = Die.Generator(n);
- System.out.println(n + "" ) ;
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement