I need to Write a program that creates a Dice object.
Your program will involve two separate classes in different files:
One class for the main method
Another class describing the Dice object
The Dice class should have fived methods (and a single class variable for storing the number on the dice):
A constructor method with the same name as the class
A roll( ) method for rolling the dice
A getValue( ) method for returning the value showing on the dice
An isEven( ) method which checks if the value is even or odd
An isHigh( ) method which checks if the value is high or low
The main application should do the following:
1. Create a Dice object
2. Roll the dice every time the user hits enter
3. Print out the new value showing on the dice
4. Print out whether the value is even or odd, high or low
So far I have this. Just wondering if someone could help me with the remaining methods
import java.util.Scanner*;
public class Dice {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Dice dice1 = new Dice();
System.out.println("dice1 is " + dice1.roll());
}
}
public class Dice{
int roll(){
return 1 + (int)(Math.random()* 6)+1;
}