-
Notifications
You must be signed in to change notification settings - Fork 1
/
Area.java
81 lines (59 loc) · 1.44 KB
/
Area.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
import java.util.ArrayList;
import java.lang.Math;
/**
*@version 2.0
*@author Joan Grau
*/
public abstract class Area{
//Atributs
protected int pos;//identificador area, va de 0 a nombreAreas-1
// private char op;//tipus operacio, sense op es casella sola
protected ArrayList<Casilla > caselles;//conte la llista de caselles
protected int res;//resultat real de l'area
protected int resact;
//Metodes
public Area(int pos){
this.pos = pos;
res = 0;
resact = 0;
caselles = new ArrayList<Casilla>();
}
abstract public String toString();
abstract public char get_operacio();
abstract public Boolean check(int n);
abstract public void calcular_resultat();
abstract public void calcular_resultatactual();
public ArrayList<Casilla> getCasellas() {
return caselles;
}
public int get_resultat(){
return res;
}
public int get_resultatactual(){
this.calcular_resultatactual();
return resact;
}
public int get_posicio(){
return pos;
}
public Boolean correcte(){
this.calcular_resultatactual();
if(res == 0) this.calcular_resultat();
return res == resact;
}
public void afegir_casella(Casilla cas){//es fara 1 cop si =;2 per - i /; 2 o mes * i +
caselles.add(cas);
}
public int get_tamany(){
return caselles.size();
}
public Casilla get_casella(int i){
return caselles.get(i);
}
public void set_casella(Casilla cas, int i){
caselles.set(i,cas);
}
public void set_res(int res){
this.res = res;
}
}