package com.example.PersonalCenter;


/*
* User类
* 作为当前登录的用户信息，保存该用户信息
* 采用单例模式
*
* */
public class User {
    private static User user;//保存某一个用户
    private String phonenumber;
    private String username;
    private String avatar_url;
    private String sex;
    private Long age;
    public static boolean isLogin;//是否登录
    private User(){}
    public static synchronized User getUser(){
        if(user == null){
            user = new User();
        }
        return user;
    }


    public static void setUser(String phonenumber, String username, String avatar_url, String sex, Long age) {
        user.setAge(age);
        user.setAvatar_url(avatar_url);
        user.setPhonenumber(phonenumber);
        user.setUsername(username);
        user.setSex(sex);

    }
    //设置登录状态
    public static void setLogin(boolean login) {
        isLogin = login;
    }
    //获取登录状态
    public static boolean isLogin() {
        return isLogin;
    }
    //注销
    public static void logoff(){
        user.setAge(null);
        user.setAvatar_url(null);
        user.setPhonenumber(null);
        user.setUsername(null);
        user.setSex(null);
        user = null;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setAvatar_url(String avatar_url) {
        this.avatar_url = avatar_url;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void setAge(Long age) {
        this.age = age;
    }

    public String getPhonenumber() {
        return phonenumber;
    }

    public String getUsername() {
        return username;
    }

    public String getAvatar_url() {
        return avatar_url;
    }

    public String getSex() {
        return sex;
    }

    public Long getAge() {
        return age;
    }
}
