-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDe.java
executable file
·56 lines (46 loc) · 1.06 KB
/
De.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import greenfoot.Actor;
import greenfoot.Greenfoot;
/**
* Classe Dé. Décrit le comportement des 2 dès du jeu.
*
* @author (Emeric de Bernis)
*/
public class De extends Actor {
private boolean used;
private int value;
private int Xcoordinate;
private int Ycoordinate;
public De(int X, int Y) {
// Initialisation des attributs et chargement de l'image
this.value = 6;
this.setImage("images/d"+this.value+".png");
this.Xcoordinate = X;
this.Ycoordinate = Y;
this.use();
}
public void act() {
}
// Lance le dé
public void roll() {
this.value = Greenfoot.getRandomNumber(6) + 1;
this.used = false;
this.setImage("images/d"+this.value+".png");
}
// Utilisation du dé : changement de l'image
public void use() {
this.used = true;
this.setImage("images/d"+this.value+"use.png");
}
public int getValue() {
return value;
}
public int getXcoordinate() {
return Xcoordinate;
}
public int getYcoordinate() {
return Ycoordinate;
}
public boolean isUsed() {
return used;
}
}