面向对象的homework 2

public class Homework3 {
public static void main(String[] args){
Student s=new Student();
System.out.println(s.getPostAddress());
Student s1=new Student(“张三”,20,“北京朝阳区”,“111111”,“1213131313”);
System.out.println(s1.getName()+“的”+s1.getPostAddress());
}
}
class Student{
private String name;
private int age;
private String address;
private String zipcode;
private String mobile;
public Student(String name,int age, String address,String zipcode,String mobile){
this.name=name;
this.age=age;
this.address=address;
this.zipcode=zipcode;
this.mobile=mobile;
}
public Student(){

}
public void setName(String name){
    this.name=name;
}
public String getName(){
    return name;
}
public void setAge(int age){
    this.age=age;
}
public int getAge(){
    return age;
}
public void setAddress(String address){
    this.address=address;
}
public String getAddress(){
    return address;
}
public void setZipcode(String zipcode){
    this.zipcode=zipcode;
}
public String getZipcode(){
    return zipcode;
}
public void setMobile(String mobile){
    this.mobile=mobile;
}
public String getMobile(){
    return mobile;
}
public String getPostAddress(){
    return "地址为:"+this.getAddress()+",邮编为:"+this.getZipcode();
}

}

你可能感兴趣的:(笔记)