class Address{
private String country;
private String province;
private String city;
private String street;
private String post;
public Address(String c,String p,String ci,String st,String po){
this.setCountry(c);
this.setProvince(p);
this.setCity(ci);
this.setStreet(st);
this.setPost(po);
}
public void setCountry(String c){
this.country=c;
}
public String getCountry(){
return country;
}
public void setProvince(String p){
this.province=p;
}
public String getProvince(){
return province;
}
public void setCity(String ci){
this.city=ci;
}
public String getCity(){
return city;
}
public void setStreet(String st){
this.street=st;
}
public String getStreet(){
return street;
}
public void setPost(String po){
this.post=po;
}
public String getPost(){
return post;
}
public String getInfo(){
return this.getCountry()+this.getProvince()+this.getCity()+this.getStreet()+this.getPost();
}
}
public class Test2{
public static void main(String[] args) {
Address ad=new Address("中国","黑龙江","哈尔滨", "学院路", "广厦学院");
ad.getInfo();
System.out.println(ad.getInfo());
}
}
编写并测试一个代表地址的Address类,包括以下属性:国家、省份、城市、街道、邮编、可以从此地址类中得到一个完整的地址信息
最新推荐文章于 2023-04-04 20:19:34 发布