第二十次发博不知道用什么标题好

package Test;

public class Superperson {
    private String name;
    private int age;

    public Superperson() {

    }

    public Superperson(String name) {
        this.name = name;
    }

    public Superperson(int age) {
        this.age = age;
    }

    public Superperson(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    
    public void setAge(int age) {
        if(age<0) {
            this.age=0;
        }else {
            this.age=age;
        }
    }
    public void printMessage() {
        System.out.println("name=" + name + ",age=" + age);
    }

    public void addAge() {
        age++;
    }

}


package Test;

public class Iperson {
    
        

    public static void main(String[] args) {
        Superperson p1 = new Superperson("小明",18);
        p1.addAge();
        p1.printMessage();
        
        Superperson p2 = new Superperson("小红");
        p2.setAge(20);
        p2.addAge();
        p2.printMessage();
        
        Superperson p3 = new Superperson();
        // TODO Auto-generated method stub

    }

}

这么久以来...第一次直接把代码复制粘贴...感觉一般般吧

posted @ 2019-04-27 01:15  18软工8班段诗媛  阅读(98)  评论(0编辑  收藏  举报