//Student.java
package test3;

public class Student {
    private int age;
    private String sex;

    // setters
    public void setAge(int age) {
        if (age >= 0 & age <= 120) {
            this.age = age;
        } else {
            this.age = 18;
        }
    }

    public void setSex(String sex) {
        if ("男".equals(sex) || "女".equals(sex)) {
            this.sex = sex;
        } else {
            this.sex = "保密";
        }
    }

    // getters
    public int getAge() {
        return age;
    }

    public String getSex() {
        return sex;
    }
}
