Question
Update BankAccount class to: Add an instance of the Customer class to your BankAccount class as an instance variable with a getter and setter method.
Update BankAccount class to:
Add an instance of the Customer class to your BankAccount class as an instance variable with a getter and setter method. The name of the instance variable should be accountHolder.
Add appropriate constructors to allow creation of bank accounts to specify an account holder.
Update the toString method such that the string returned includes account holder information.
Add a method called transfer that takes an amount to transfer and an account to transfer to as arguments. The transfer should only take place if the account has enough funds.
That's my bankAcount code. no prompt for user imput
public class BankAccount{ private double balance; private String accountNumber;
public BankAccount(){ this.balance = 0.0; this.accountNumber = "0001"; }
public BankAccount(double balance){ this.balance = balance; this.accountNumber = "0001"; }
public BankAccount(double balanceToStart, String accountNumberToStart){ this.balance = balanceToStart; this.accountNumber = accountNumberToStart; }
public double getBalance(){ return this.balance; }
public String getAccountNumber(){ return this.accountNumber; }
public String toString(){ return this.getAccountNumber() + ": " + this.getBalance(); }
public void deposit(double amount){ if(amount >= 0) { double check = this.balance + amount; this.balance = check; } }
public void withdraw(double amount){ if(amount >= 0 && this.balance >= amount) { this.balance = this.balance - amount; } }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started