package _02_private;

public class Person {
    private String name;
    private Integer age;
    private String gender;

    /**
     * 当我们给属性私有化private
     * 想要设置属性或者是获取属性必须给属性提供公共set 和get 方法
     * public void set属性名(String n){
     *     name = n
     * }
     *
     * public String get属性名(){
     *     return name;
     * }
     */
    public void setName(String n){
        name = n;
    }

    public String getName(){
        return name;
    }

    public void setAge(int a){
        if(a>0 && a<=100){
            age = a;
        }else{
            System.out.println("年龄不合法请输入在1-100之间");
        }
    }

    public int getAge(){
        return age;
    }

    public void setGender(String g){
        if(g.equals("男")|| g.equals("女")){
            gender = g;
        }else{
            System.out.println("输入性别不合法,请输入男或者是女");
        }
    }

    public String getGender(){
        return gender;
    }

    public void eat(){
        System.out.println("吃饭");
    }

    private void sleep(){
        System.out.println("睡觉");
    }
}
