working on a bet. A friend gave me some java projects and to win my bet I had to figure out how to do them in a week. trying to get them finnished and working by tonight.
first one.
Write a Java class called Die (as in the singular of Dice) that represents one die with faces showing values between 1 and 6. It should contain :
--one integer instance variable, faceValue, that represents the current face value of the die, an integer constant (MAX) that represents the maximum face value of the die.
--a constructor
--and five regular methods: roll, setFaceValue, getFaceValue, toString and equals.
* The roll method should compute a random integer between 1 and 6 and set the current face value with that as a way of simulating the rolling of the die. (What Java class and method would you use to get a random integer ?? find out..)
* Now, write a driver (i.e., program used for testing) called RollingDice, in order to test your Die class.
ive got this so far but when I try to run it my console stays clear... idk what im doing wrong
*Edited: [;ease
first one.
Write a Java class called Die (as in the singular of Dice) that represents one die with faces showing values between 1 and 6. It should contain :
--one integer instance variable, faceValue, that represents the current face value of the die, an integer constant (MAX) that represents the maximum face value of the die.
--a constructor
--and five regular methods: roll, setFaceValue, getFaceValue, toString and equals.
* The roll method should compute a random integer between 1 and 6 and set the current face value with that as a way of simulating the rolling of the die. (What Java class and method would you use to get a random integer ?? find out..)
* Now, write a driver (i.e., program used for testing) called RollingDice, in order to test your Die class.
ive got this so far but when I try to run it my console stays clear... idk what im doing wrong
public class Die { public static void main (String[] args) { } protected int value; private static final int HIGHEST_DIE_VALUE = 6; private static final int LOWEST_DIE_VALUE = 1; public Die () { value = ((int) (Math.random() * 100) % HIGHEST_DIE_VALUE + LOWEST_DIE_VALUE); } public int getValue () { return value; } }
*Edited: [;ease
