3
Cliente
and Fornecedor
has name, phone and email in common what is the best way for me to treat this, should I create these variables in common in the abstract class? or is there a better way for me to do that?
Pessoa (Abstract):
public abstract class Pessoa {
public abstract String getNome();
public abstract String getEmail();
public abstract String getTelefone();
}
Customers:
public class Cliente extends Pessoa{
public String nome;
public String email;
public String telefone;
public String cpf;
public String rg;
Cliente(String nome, String email, String telefone,String cpf, String rg){
this.nome=nome;
this.email=email;
this.telefone=telefone;
this.cpf=cpf;
this.rg=rg;
}
public String getNome(){ return this.nome;}
public String getEmail(){return email;}
public String getTelefone(){return this.telefone;}
public String getCpf(){return this.cpf;}
public String getRg(){return this.rg;}
}
Supplier:
public class Fornecedor extends Pessoa{
public String nome;
public String email;
public String telefone;
public String cnpj;
public Long inscricaoestadual;
Fornecedor(String nome, String email, String telefone,String cnpj, Long
inscricaoestadual){
this.nome=nome;
this.email=email;
this.telefone=telefone;
this.cnpj=cnpj;
this.inscricaoestadual=inscricaoestadual;
}
public String getNome(){ return this.nome;}
public String getEmail(){return email;}
public String getTelefone(){return this.telefone;}
public String getCnpj(){return this.cnpj;}
public Long getIncricaoestadual(){return this.inscricaoestadual;}
}
I understand your position. But I cannot see an answer in your answer, the way forward so that I can resolve my doubt. good everything I write I learn in college, of course you will criticize but I do not get restricted to classroom too, so I am here, you sent thousands of information I ended up getting lost and I do not know where begins or ends the "error" or bad practice.
– Vitor Gonçalves
That’s a problem nowadays. Everyone wants it ready and can’t build knowledge. Just read the first paragraph and forget the rest. Leave the rest to the people who want to learn to do it right. The first sentence is what you want. I’m sorry, I always try to teach right and forget that people just want the cake recipe.
– Maniero
Analyzing your answer more calmly I see that it is more complete than just an answer to my question, thank you very much, sorry for previous messages.
– Vitor Gonçalves