-
Notifications
You must be signed in to change notification settings - Fork 0
/
Despesa.java
73 lines (58 loc) · 1.74 KB
/
Despesa.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
import java.io.Serializable;
//classe abstrata não dá para criar instâncias
public abstract class Despesa implements Serializable{
private double deducao;
private double maximo;
private String code;
static final long serialVersionUID = 6L;
public Despesa(double deducao,double maximo, String code){
this.deducao=deducao;
this.maximo=maximo;
this.code = code;
}
public Despesa(Despesa d){
this.deducao=d.getDeducao();
this.maximo=d.getMaximo();
this.code = d.getCode();
}
public double getDeducao(){
return this.deducao;
}
public void setDeducao(double d){
this.deducao=d;
}
public double getMaximo(){
return this.maximo;
}
public void setMaximo(double m){
this.maximo=m;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public String toString(){
StringBuilder sb =new StringBuilder();
sb.append("Deducao: ");
sb.append(this.deducao + "\n");
sb.append("Maximo: ");
sb.append(this.maximo + "\n");
sb.append("Código: ");
sb.append(this.code + "\n");
return sb.toString();
}
public boolean equals(Object o){
if(this==o)
return true;
if(o==null || o.getClass()!=this.getClass())
return false;
Despesa d=(Despesa) o;
return(this.deducao== d.getDeducao()
&& this.maximo == d.getMaximo()
&& this.code.equals(d.getCode()));
}
//as outras classes tem de ter o clone definido e o clone que é chamado é dessa classe
public abstract Despesa clone();
}