-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefactoredCustomerAccount.java
More file actions
57 lines (45 loc) · 1.24 KB
/
Copy pathRefactoredCustomerAccount.java
File metadata and controls
57 lines (45 loc) · 1.24 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
52
53
54
55
56
57
import java.util.ArrayList;
import java.util.List;
public class CustomerAccount {
private String number;
private double balance;
private List<AccountTransaction> transactionList;
public CustomerAccount() {
this.number = "";
this.balance = 0.0;
this.transactionList = new ArrayList<>();
}
public CustomerAccount(String number, double balance) {
this.number = number;
this.balance = balance;
this.transactionList = new ArrayList<>();
}
public String getNumber() {
return number;
}
public double getBalance() {
return balance;
}
public List<AccountTransaction> getTransactionList() {
return transactionList;
}
public void setNumber(String number) {
this.number = number;
}
public void setBalance(double balance) {
this.balance = balance;
}
public void addTransaction(AccountTransaction transaction) {
transactionList.add(transaction);
}
public void deposit(double amount) {
balance += amount;
}
public boolean withdraw(double amount) {
if (balance >= amount) {
balance -= amount;
return true;
}
return false;
}
}