0
Taking into account the classes below, how can I - within the Bank class - store within the Arraylist all my customers?
Bench
public class Banco {
private ArrayList<Conta> contas;
public Banco() {
contas = new ArrayList<Conta>();
}
}
Client
public class Cliente {
private String nome;
private String telefone;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
}
Bill
public class Conta {
private int numero;
private double saldo;
private Cliente cli;
public Conta() {
}
public int getNumero() {
return numero;
}
public void setNumero(int numero) {
this.numero = numero;
}
public double getSaldo() {
return saldo;
}
public void setSaldo(double saldo) {
this.saldo = saldo;
}
public Cliente getCli() {
return cli;
}
public void setCli(Cliente cli) {
this.cli = cli;
}
}
The important thing is to work :)
– Ana
Could put the code of the part where creates the customers, the accounts and the bank?
– Skywalker
The objects
Conta
already have a reference to its objectCliente
, so the bank does not store customers, but stores accounts that have references to their respective customers. There is nothing wrong with this idea and the modeling of the classes is correct, I did not understand your doubt.– Marciano.Andrade
My goal is to create a method within the Bank class that lists names and phones of customers who have negative balance
– Ana
Um yes, I added this method to my reply. I confess that I initially got a bit confused.
– Skywalker