I have the Accounts Java class as follows:
public class Accounts {
These are the fields
private int accountNumber;
private String accountName;
private double accountBalance;
public Accounts(int accountNumber, String accountName, double accountBalance) {
this.accountNumber = accountNumber;
this.accountName = accountName;
this.accountBalance = accountBalance;
}
public int getAccountNumber() {
return accountNumber;
}
public String getAccountName() {
return accountName;
}
public double getAccountBalance() {
return accountBalance;
}
public void setAccountNumber(int accountNumber) {
this.accountNumber = accountNumber;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setAccountBalance(double accountBalance) {
this.accountBalance = accountBalance;
}
}
public class AccountController {
ArrayList<Accounts> accounts = new ArrayList<>();
public boolean addAccount(int accountNumber, String accountName, double accountBalance) {
Accounts acc = new Accounts(accountNumber, accountName, accountBalance);
if (findAccount(accountNumber) == null) {
accounts.add(acc);
return true;
}
return false;
}
These are the classes I have: 1: Accounts 2: Account Controller 3: MyMainView
I want to print the list of the Accounts I add to the ArrayList along which contains accountNumber , accountBalance and accountName. I want to add the create the method inside the MyMainView and call it inside the main method of the MyMainView.