I want the this.person0 and this.person1 to function, truth be told I don't completely understand whats happening, a lecturer gave me the code and says fix errors and I have been coding for less than a month. All of this is over my head, fixing code is good but explanations are even better, I've tried looking at other answers here but unless it relates close enough I just can't understand it.
public class BankApp {
public static void main(String args[]) {
BankApp ba = new BankApp();
class SavingsAccount {
private String Balance;
private String ID;
private String Name;
private SavingsAccount person0;
private SavingsAccount person1;
public void BankApp() {
// A SavingsAccount object cannot be created without an ID, name and an initial balance.
this.person0 = new SavingsAccount("AL01", "Luis Alvarez", 1.00);
this.person1 = new SavingsAccount("BE01", "Elizabeth Blackwell", 2000.00);
// The get... methods are accessors for various private member variables of that object
// Their return types must match the types of the member variables being returned.
System.out.println(person0.getBalance() + " " + person0.getID() + " " + person0.getName());
}
}
}
// The withdraw method takes an amount to withdraw as its parameter.
// Return values:
// true when there are sufficient funds (and when the withdrawal is performed).
// false when there are insufficient funds.
if (this.person0.withdraw(1000))
System.out.println("Done");
else
System.out.println("Insufficient funds");
//The deposit method takes an amount to deposit as its parameter. It does not perform
// the deposit if the value is negative.
this.person1.deposit(1500);
//The transfer method takes a beneficiary SavingsAccount object and an amount as its parameters
// then transfers that amount if sufficient funds are present in the "from" account object.
// Return values: Similar to the withdraw method above.
if (this.person1.transfer(this.person0, 50000))
System.out.println("Done");
else
System.out.println("Insufficient funds");
System.out.println("Balance for " + this.person0.getID() + " = " + this.person0.getBalance());
System.out.println("Balance for " + this.person1.getID() + " = " + this.person1.getBalance());
}
}
}
}