Yes i can resist. But i did use the code to help me out (didn't copy it just used as reference)
But new question. I have to prompt user to enter what kind of dice they want to use. then random the number and return it. Must also use:
* int roll(): sets (and returns) the face value to a uniform random number between 1 and the number of faces
* int getFaceValue(): returns the current face value of the die
* String toString(): returns the string representation of the face value
Lots of errors, but using the posted code tried to figure it out.
Code:
import java.util.Random;
public class Die {
public static void main(String[] args) {
System.out.println("Which dice would you like to use? 4, 6, 8, 10, 12, 20, and 100:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int anwser = 0;
try {
anwser = br.readLine();
}
catch (IOException ioe) {
System.out.println("IO error trying to read your Die");
System.exit(1);
}
RollDic roll = new RollDic();
roll.roll();
System.out.println("Your Roll resulted in an:" + randomNum + "");
}
}
public class RollDie {
int result = 0;
public RollDie(){}
public int roll() {
Random generator = new Random();
int randomNum = generator.nextInt(anwser + 1);
result = randomNum;
}
public int GetFaceValue() {
return result;
}
}
Editing as i fix errosr