2
import javax.swing.JOptionPane;
public class Cliente {
private String nome;
private String telefone;
private int codigo;
private String rua;
void setRua(String z) {
rua = z;
}
void setTelefone(String t) {
telefone = t;
}
void setCodigo(int n) {
codigo = n;
}
void setNome(String name) {
this.nome = name;
}
int getCodigo(){
return codigo;
}
void cadastroCliente(Cliente cliente, int n) {
cliente.setCodigo(n);
cliente.setNome(JOptionPane.showInputDialog("Nome: "));
cliente.setTelefone(JOptionPane.showInputDialog("Telefone: "));
cliente.setRua(JOptionPane.showInputDialog("Rua: "));
}
void removerCliente(Cliente cliente, int n) {
cliente.setNome("");
cliente.setTelefone("");
cliente.setRua("");
}
void mostrarClientes(Cliente[] cliente) {
for (int i = 0; i < cliente.length ; i++) {
if ((cliente[i].getCodigo() != 0 ) && (cliente[i].nome != null)) {
JOptionPane.showMessageDialog(null, cliente[i].nome);
}
}
}
}
Below the code main.. where is my doubt..
import javax.swing.JOptionPane;<
public class Operacoes {
public static void main(String[] args) {
Cliente teste = new Cliente();
Cliente cliente[] = new Cliente[30];
cliente[1] = new Cliente();
cliente[2] = new Cliente();
cliente[3] = new Cliente();
cliente[1].cadastroCliente(cliente[1], 1);
cliente[2].cadastroCliente(cliente[2], 2);
cliente[3].cadastroCliente(cliente[3], 3);
teste.mostrarClientes(); // Não sei o que colocar dentro do ()
}
}
I already told you that the structure of your code is all wrong. You are mixing things. It seems strange to me that you can create array, create a method that receives a array and does not know how to pass the array as argument. I think you need to take a programming courses before you start trying to program. Your name is Igor or Rodrigo? http://answall.com/users/21284/igor-gutemberg
– Maniero
Related: http://answall.com/questions/10869/como-chamar-um-m%C3%A9all-when-your-even%C3%A2metro-%C3%A9-a-array
– ptkato
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero