-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccount.pde
47 lines (41 loc) · 1017 Bytes
/
Account.pde
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
public class Account {
public String name;
public double amount;
public String id;
public boolean frozen = false;
/**
* Deposits the amount given into the account
* REturns if the deposit was succesful
*/
public boolean deposit(double money) {
amount += money;
return true;
}
/**
* Withdraws the amount from the account
* Returns false if the withdraw was calcled due to not having enoguth money
*/
public boolean withdraw(double money) {
if (money > amount) {
return false;
}
amount -= money;
return true;
}
public String toString() {
return name + " $" + amount + (frozen ? "FROZEN" : "") + " \n id:" + id;
}
public Account(String name, double amount, String id) {
super();
this.name = name;
this.amount = amount;
this.id = id;
}
public Account(String name, double amount, String id, boolean frozen) {
super();
this.name = name;
this.amount = amount;
this.id = id;
this.frozen = frozen;
}
}