Define and implement a Citizen class Citizen, the class includes the characteristics of information include: ID ID, Name, Name, Gender, Gender, Age, Age, domicile of origin, for home address Familyaddress properties and constructor (with no parameters), the Input method of information Input and output citizens Print information methods, requirements to the class object is initialized, Input and output operations,
Reference sample:
Public class Citizen
{
Public string ID {set; The get; }
//...
Public Citizen ()
{
//data of the default
}
Public void Input (string id, string name...).
{
ID=ID;
//...
}
CodePudding user response:
Is to create a class, I also just learn Java, wrote the code is not an error, just don't know operators do not conform to the requirements,Public class Citizen {
Private int id;
Private String name;
Private String gender;
private int age;
Private String for;
Private String familyaddress;
Public Citizen () {
}
Public int getId () {
return id;
}
Public void setId (int id) {
this.id=id;
}
Public String getName () {
return name;
}
Public void elegantly-named setName (String name) {
this.name=name;
}
Public String getGender () {
Return the gender;
}
Public void setGender (String gender) {
This. Gender=gender;
}
Public int getAge () {
Return the age;
}
Public void setAge (int age) {
this.age=age;
}
Public String getBirthplace () {
Return for;
}
Public void setBirthplace (String) for {
This. For=for;
}
Public String getFamilyaddress () {
Return familyaddress;
}
Public void setFamilyaddress (String familyaddress) {
Enclosing familyaddress=familyaddress;
}
Public void input (int id, String name, String gender, int the age, the String for, String familyaddress) {
This. Id=id;
}
Public void print (int id) {
This. Id=id;
System. The out. Println (" ID "+ ID);
}
}
CodePudding user response:
Recommend you use an initialized and construction operation