-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonte.java
More file actions
36 lines (33 loc) · 880 Bytes
/
Monte.java
File metadata and controls
36 lines (33 loc) · 880 Bytes
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
// Implementa um monte de vários baralhos de cartas
public class Monte {
private int c=0;
private Baralho baralhos[] = new Baralho[BlackJack.numBaralhos];
private Carta cartas[] = new Carta[BlackJack.numBaralhos*Baralho.tamanho];
// Cria o monte com o array de baralhos definido
public Monte() {
super();
int k=0;
for(int i=0; i<baralhos.length; i++){
baralhos[i] = new Baralho();
for(int j=0; j<Baralho.tamanho; j++){
cartas[k] = baralhos[i].GetCarta(j);
k++;
}
}
}
// Embaralha todas as cartas
public void embaralhar() {
Carta temp;
for(int i=0; i<cartas.length; i++){
int j = (int)Math.round(Math.random()*(cartas.length-1));
temp=cartas[j];
cartas[j]=cartas[i];
cartas[i]=temp;
}
c=0;
}
// Devolve a próxima carta do monte
public Carta getCarta() {
return cartas[c++];
}
}