In my program; I have an object which stores name, description, languages that he/she speaks, when created, address, reputation. But the must have fields are name, description, languages and the others are non compulsory. I don't want to write two methods and let user select one and the make other fields null according to usage, such as;
inside of constructor(name, description, languages) {
this.name = name;
this.description = description;
this.languages = languages;
this.address = " ";
this.reputation = " ";
}
inside of constructor(name, description, languages, address, reputation) {
this.name = name;
this.description = description;
this.languages = languages;
this.address = address;
this.reputation = reputation;
}
So how can I solve this problem? Is there a way I can create fields according fields that user provides?
I am using java.
Thanks in advance.