10.23创造人第9次作业

package cn.wzx.www;

public class Person {
    private int id;
    private String name;
    private int age;
    private String sex;
    public String introduce()
    {
        return  "My id=" + id + ", name=" + name + ", age=" + age + ", sex=" +sex ;
    }
    
    public Person(int id,String name,int age,String sex) {
        // TODO 自动生成的构造函数存根
        this.id=id; 
        this.name=name;
        this.age=age;
        this.sex=sex;
    }
    
    public void setId(int id)
    {
        this.id=id;
    }
    
    public void setName(String name)
    {
        this.name=name;
    }
    
    public void setAge(int age)
    {
        this.age=age;
    }
    public void setSex(String sex)
    {
        this.sex=sex;
    }
    public int getId()
    {
        return this.id;
    }
    public String setName()
    {
        return this.name;
    }
    
    public int setAge()
    {
        return this.age;
    }
    public String setSex()
    {
        return this.sex;
    }
    
}

package cn.person.www;
 
public class Demoperson {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        person p1=new person(001,"刘备",40,"北京");
        person p2=new person(002,"关羽",37,"北京");
        person p3=new person(003,"张飞",45,"北京");
        person p4=new person(004,"诸葛亮",25,"北京");
         
        System.out.println(p1.introduce());
        System.out.println(p2.introduce());
        System.out.println(p3.introduce());
        System.out.println(p4.introduce());
         
    }
 
}


posted on 2017-10-30 14:34  kally1004  阅读(68)  评论(0编辑  收藏  举报

导航