I have a line in my homework that I'm having a hard time with.
You are supposed to provide methods to withdraw and deposit a given amount of money from an account and a transfer method that transfers given amount of money from one account to another. The transfer method can be called by using the class name.
I don't quite understand what the last sentence means. Here is what I have;
public class CbtBank {
private double balance;
private String firstName, lastName;
private int accountNumber;
public CbtBank(String firstName, String lastName, int accountNumber, double balance) {
this.balance = balance;
this.firstName = firstName;
this.lastName = lastName;
this.accountNumber = accountNumber;
}
public void transfer(CbtBank from, CbtBank to, double amount){
to.balance += amount;
from.balance -= amount;
}
}
And my main.java;
public static void main(String[] args) {
CbtBank person1 = new CbtBank("can", "berk", 3123, 100.0);
CbtBank person2 = new CbtBank("can2", "berk2", 3124, 200.0);
CbtBank.transfer(person1, person2, 50.0);
}
I can't get it to work this way but I'm not even sure if this is meant. Any ideas?