public class BankAccount{
private String accountNum;
private double balance;
public String name;
//this is a constructor
public BankAccount (String accountNum, double balance, String name){
this.accountNum = accountNum;
this.balance = balance;
this.name = name;
}
//this is a constructor
public BankAccount (String accountNum, String name){
this.accountNum = accountNum;
this.balance = 0;
this.name = name;
}
//this is a method
public boolean withdrawal(double amount){
if (this.balance >= amount && amount > 0){
this.balance -= amount;
return true;
}
else{
StdOut.println("Error wiwth withdrawal");
return false;
}
}
//this is a method
public boolean deposit(double amount){
if (amount < 0){
StdOut.println("Error with deposit");
return false;
}
else {
this.balance += amount;
return true;
}
}
//this is a method
public void transfer(BankAccount to, double amount){
if (this.withdrawal(amount)){
to.deposit(amount);
}
else {
StdOut.println("Error with transfer");
}
}
}