-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathEuro.java
More file actions
52 lines (41 loc) · 834 Bytes
/
Euro.java
File metadata and controls
52 lines (41 loc) · 834 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package code.database;
public class Euro {
private long valore;
public Euro(long euro, long cent) {
if (euro >= 0) {
valore = euro*100 + cent;
} else {
valore = euro*100 - cent;
}
}
public Euro(double d) {
valore = (long)(d*100);
}
public long getValore() {
return valore;
}
public Euro somma(Euro e) {
this.valore = this.valore + e.getValore();
return this;
}
public Euro sottrai(Euro e) {
this.valore = this.valore - e.getValore();
return this;
}
public boolean ugualeA(Euro e){
if (valore == e.getValore())
return true;
else return false;
}
public boolean minoreDi(Euro e){
if (valore <= e.getValore())
return true;
else return false;
}
public int getEuro() {
return (int)(this.valore / 100);
}
public String stampa(){
return (double)valore/100 +" euro";
}
}