-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoney3.java
More file actions
38 lines (29 loc) · 810 Bytes
/
Copy pathMoney3.java
File metadata and controls
38 lines (29 loc) · 810 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
package hashCodeEquals.example1;
public class Money3 {
private int amount;
private String currencyCode;
public Money3(int amount, String currencyCode) {
super();
this.amount = amount;
this.currencyCode = currencyCode;
}
@Override
public boolean equals(Object obj) {
//super.equals(obj);
boolean isAmountEqual = this.amount == ((Money3) obj).getAmount();
boolean isCodeEqual = this.currencyCode.equals(((Money3) obj).getCurrencyCode());
return isAmountEqual && isCodeEqual;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public String getCurrencyCode() {
return currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
}