package _04_构造方法;

public class User {
    private String username;
    private String password;
    private String confirmPassword;
    private String email;
    private String gender;
    private int age;


    public User() {
    }

    public User(String username, String password, String confirmPassword, String email, String gender, int age) {
        this.username = username;
        this.password = password;
        this.confirmPassword = confirmPassword;
        this.email = email;
        this.gender = gender;
        this.age = age;
    }


    /**
     * 提供一个注册方法
     * 注册用户信息
     * register(String username,
     * String password,
     * String confirmPassword,
     * String email,String gender,int age){
     * // 判断账号和密码不能为空
     * // 判断输入密码和重复输入相等
     * // 判断性别必须是男或者女
     * // 判断年龄必须是0-100 之间
     * <p>
     * }
     */
    public void register(String username, String password,
                         String confirmPassword,
                         String email, String gender, int age) {
        // 判断账号和密码不能为空
        if(username == null || password == null){
            System.out.println("账号和密码不能为空");
            return;
        }
        // 判断输入密码和重复输入相等
        if(!password.equals(confirmPassword)){
            System.out.println("两次输入的密码不一致");
            return;
        }
        // 判断性别必须是男或者女
        if(!(gender.equals("男") || gender.equals("女"))){
            System.out.println("性别必须为男或者是女");
            return;
        }
        // 判断年龄必须是0-100 之间
        if(age<=0  || age>100){
            System.out.println("输入年龄是不合法的");
            return;
        }
        User user = new User(username,password,confirmPassword,email,gender,age);
        System.out.println("注册成功!!");
        System.out.println(user);
    }

    /**
     * 获取
     *
     * @return username
     */
    public String getUsername() {
        return username;
    }

    /**
     * 设置
     *
     * @param username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * 获取
     *
     * @return password
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置
     *
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 获取
     *
     * @return confirmPassword
     */
    public String getConfirmPassword() {
        return confirmPassword;
    }

    /**
     * 设置
     *
     * @param confirmPassword
     */
    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    /**
     * 获取
     *
     * @return email
     */
    public String getEmail() {
        return email;
    }

    /**
     * 设置
     *
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * 获取
     *
     * @return gender
     */
    public String getGender() {
        return gender;
    }

    /**
     * 设置
     *
     * @param gender
     */
    public void setGender(String gender) {
        this.gender = gender;
    }

    /**
     * 获取
     *
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "User{username = " + username + ", password = " + password + ", confirmPassword = " + confirmPassword + ", email = " + email + ", gender = " + gender + ", age = " + age + "}";
    }
}
