-
Notifications
You must be signed in to change notification settings - Fork 1
/
Casilla.java
105 lines (83 loc) · 1.81 KB
/
Casilla.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//Made by Yeray Bosoms Blasco 4-11-15
//new modification 10-11-15
import java.util.ArrayList;
public class Casilla{
// Datos
protected int valor;
protected boolean fija;
protected int solucion;
protected ArrayList<Integer> can;
//funciones
public Casilla(){
valor = -1;
fija = false;
solucion = 0;
can = new ArrayList<Integer>(0);
}
public String toString(){
String res = "";
res = "valor: " + this.valor + ", "
+ "fija: " + this.fija + ", "
+ "solucion: " + this.solucion + ", "
+ "posibilidades: " + this.can;
return res;
}
public Casilla (int valor, boolean fija, int solucion){
this.valor= valor;
this.fija = fija;
this.solucion = solucion;
can = new ArrayList<Integer>(0);
}
public Casilla clonaCasilla(){
Casilla aux = new Casilla(valor, fija, solucion);
for(int i = 0; i<can.size(); ++i){
Integer aux2 = can.get(i);
aux.addCan(aux2.intValue());
}
return aux;
}
public boolean getLlena(){
return ((-1) != valor);
}
public int getValor(){
return valor;
}
public int getCan(int x){
if (can.size()>x) return can.get(x).intValue();
else return -1;
}
public void addCan(int x){
Integer aux = new Integer(x);
if(!can.contains(aux))can.add(aux);
}
public boolean candidato(int x){
return can.contains(new Integer(x));
}
public void borrarcandidatos(){
can.clear();
}
public int numerocandidatos(){
return can.size();
}
public void quitarcandidato(int x){
can.remove(new Integer(x));
}
public boolean getFija(){
return fija;
}
public int getSolucion(){
return solucion;
}
public void setFija(boolean estafija){
fija = estafija;
}
public void vaciar(){
valor = -1;
}
public void setValor(int valor_a_dar){
valor = valor_a_dar;
}
public void setSolucion(int solucion_a_dar){
solucion = solucion_a_dar;
}
}