forked from olivviaN/JavaLabTestRepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDice.java
41 lines (36 loc) · 826 Bytes
/
Dice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Represents a Dice in a game
*
* @author (jim buckley)
* @version (14/01/2019)
*/
import java.lang.Math;
public class Dice
{
// instance variables - replace the example below with your own
private int faceUp;
/**
* Constructor for objects of class Dice
*/
public Dice()
{
// initialise instance variables
faceUp = 0;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void rollDice()
{
// gets a random value for the dice, and places it in faceUp
faceUp=((int)Math.random()*6)+1;
}
public int reportDice()
{
//reports the current value of the dice
return(faceUp);
}
}