这是我编写的一个包含地址信息的构造函数,但我在最后一部分遇到了问题,我必须返回一个包含名称、地址、城市、州邮政编码的字符串。写它的正确方法是什么?
公共类地址{
private String name;
private String address;
private String state;
private String city;
private String zipcode;
public Address(String name, String address, String state, String city, String zipcode){
this.name = name;
this.address = address;
this.state = state;
this.city = city;
this.zipcode = zipcode;
}
public Address(){
name = "occupant";
address = " ";
state = " ";
city = " ";
zipcode = " ";
}
public void setAddress(String Address){
this.address = Address;
}
public void setstate(String state){
this.state= state;
}
public void setcity(String city){
this.city = city;
}
public void setzipcode(String code){
this.zipcode = code;
}
public String getaddress(){ // Return string that contains name and address and city and zipcode
return getaddress() + " " + return state + " " + return city + " " + return code;
}
}