Is there a way to pass the value of a specific method from one class to another? For instance if i wanted to take the results of this:
Code:
void withdraw(double amt){
balance = balance - amt;
if (balance < 0) {
sendWarning();
applyOverdraftFee();
}
}
And use it in another class like this:
Code:
public String errorDescription(double balance, BankAccount toAccount)
{
BankAccount method = new BankAccount(balance, acctNumber, acctNumber, acctNumber);
this.toAccount = toAccount;
if(method.balance >0){
return "ERR2556B - insufficient funds"; }
else
return "ERR2312A - not authorized to make this transfer amount";
Basically I am trying to take what ever value is returned from the withdraw method and use it in my other method which is located in another class. If the withdraw method returns a value less then 0, the errorDescription will take that value and print ERR2556B - insufficient funds.
The second class can not be extended if that is an option since its already being extended from another class.