anyone here that knows java and wants to help me?
There is this program I have to make a random dice generator and I have to have one die object but let it generate 3 numbers anyone know how to do it?
forgot to add the other file
thats all I got so far.
I guess I can offer you credits
There is this program I have to make a random dice generator and I have to have one die object but let it generate 3 numbers anyone know how to do it?
Code:
class DieRoll {
public static void main ( String [] args) {
String space;
space = " ";
Die die;
die = new Die();
die.roll();
System.out.println("Your Results are" + space + die.getRoll());
}
}
Code:
import java.util.*;
class Die {
private int number;
private static final int MAX_NUMBER = 6;
private static final int MIN_NUMBER = 1;
private static final int NO_NUMBER = 0;
//Constructor
public Die() {
number = NO_NUMBER;
}
//Roll a Die
public void roll() {
number = (int) Math.floor((Math.random() * (MAX_NUMBER - MIN_NUMBER +1) +1));
}
// Get number from roll
public int getRoll() {
return number;
}
}
I guess I can offer you credits









Comment