-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.java
46 lines (31 loc) · 1.07 KB
/
Customer.java
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
package com.company;
import java.text.DecimalFormat;
import java.util.ArrayList;
public class Customer {
private static final DecimalFormat df = new DecimalFormat("0.00");
private String name;
private ArrayList<Double> transactions;
private Branch myBranch;
public Customer(String customerName,
double startingBalance) {
this.transactions = new ArrayList<Double>();
this.name = customerName;
transactions.add(startingBalance);
}
public String getName() {
return name;
}
public ArrayList<Double> getTransactions() {
return transactions;
}
public void addTransaction(double deposit){
//already verified identity in the overloaded version.
int index = (transactions.size()-1);
double last = (transactions.get(index));
double x = deposit+last;
transactions.add(x);
System.out.println("Deposit of " + df.format(deposit) + " has been " +
"made. Your " +
"new total is " + df.format(x) + ".");
}
}