-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBill.java
More file actions
51 lines (41 loc) · 1.08 KB
/
Copy pathBill.java
File metadata and controls
51 lines (41 loc) · 1.08 KB
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
/*
* A bill, which contains a value and a serial number. These are deposited from the ATM, and are
* used in the vault.
*/
public class Bill {
private final int amount;
private enum CurrencyType {
CAD, US
}
private CurrencyType currency;
private final int serialNumber;
private boolean isTorn;
@Override
public String toString() {
return "Bill [amount=" + amount + ", currency=" + getCurrency() + ", serialNumber="
+ serialNumber + ", isTorn=" + isTorn + "]";
}
public Bill(int amount) {
this.amount = amount;
serialNumber = Utilities.randNumber(100000, 10000000);
// a 10% chance the bill is torn
if (Utilities.randProbability(0.1)) {
this.isTorn = true;
}
}
public int getAmount() {
return amount;
}
private String getCurrency() {
return currency.toString();
}
public void setCurrency(CurrencyType currency) {
this.currency = currency;
}
public boolean getIsTorn() {
return isTorn;
}
public int getSerialNumber() {
return serialNumber;
}
}