-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDe.java
More file actions
65 lines (57 loc) · 1.02 KB
/
De.java
File metadata and controls
65 lines (57 loc) · 1.02 KB
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
57
58
59
60
61
62
63
64
65
import java.util.Random;
public class De {
int de;
public De() {
de = 0;
}
public int lancerDe() {
Random r = new Random();
de = (r.nextInt(3)+1);
return de;
}
public int lancerDes(int nb) {
De de = new De();
int res;
int compt = 0;
for (int i=0;i<nb;i++) {
res = de.lancerDe();
compt = compt+res;
}
return compt;
}
public int convert(int expl) {
int res;
int compteur;
if (expl%3==0) {
compteur = expl/3;
//System.out.println(compteur+"D");
res = this.lancerDes(compteur);
return res;
}
int bla = expl;
int compt = 0;
while (!(bla%3==0)) {
bla -= 1;
}
compt = expl-bla;
compteur = bla/3;
//System.out.println(compteur+"D+"+compt);
bla = this.lancerDes(compteur);
return bla+compt;
}
public String affichage(int res) {
int compteur;
if (res%3==0) {
compteur = res/3;
return compteur+"D";
}
int bla = res;
int compt = 0;
while (!(bla%3==0)) {
bla -= 1;
}
compt = res-bla;
compteur = bla/3;
return compteur+"D+"+compt;
}
}