日期:2014-05-20  浏览次数:20659 次

java 题目 编写一个代表地址的Address类,地址信息由国家,省份,城市,街道,邮编组成,并且可以返回完整的地址信息!并用测试类 进行测试!
请高手给于程序案例!

------解决方案--------------------
纯数据类,没什么需要测试的。
Java code
public final class Address {
    public final String country;
    public final String province;
    public final String city;
    public final String street;
    public final String postcode;
    public Address(String country,String province,String city,String street,String postcode){
        this.country = country;
        this.province = province;
        this.city = city;
        this.street = street;
        this.postcode = postcode;
    }

    @Override String toString(){
        return String.format("Address[country:%s, province:%s, city:%s, street:%s, postcode:%s]",country,province,city,street,postcode);
    }
}