Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package eecs1022.lab5;
- /**
- * Created by user on 3/14/18.
- */
- public class Client {
- public String name;
- public double balance;
- Transaction[] history = new Transaction[10];
- int not = 0; // number of transactions
- //Client Constructor
- public Client(String name, double balance){
- this.name = name;
- this.balance = balance;
- }
- //Deposits a set amount of money into the balance
- public void deposit(double amount){
- balance = balance + amount;
- history[not] = new Transaction("Deposit", amount);
- not++;
- }
- //Withdraws a set amount of money into the balance
- public void withdraw(double amount){
- balance = balance - amount;
- history[not] = new Transaction("Withdraw", amount);
- not++;
- }
- //Method that gets the history of the specific client
- public String getHistory(){
- String s = "";
- for(int i = 0; i < not; i++){
- s += history[i].toString() + "\n";
- }
- return s;
- }
- //toString Method
- @Override
- public String toString()
- {
- String s = "Statement of Client " + name + " (current balance $"+ String.format("%.2f", balance) + "):" + "\n";
- s += getHistory();
- return s;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement