import java.util.*; // For Date, Vector

public class UBUser {
    public static final int USER_FLAG_GUEST = 0;
    public static final int USER_FLAG_STUDENT = 1;
    public static final int USER_FLAG_ADMIN = 2;
    public static final int USER_FLAG_TEACHER = 3;
    public static final int USER_FLAG_CAN_RESERVE_ROOMS = 4;
    public static final int USER_FLAG_SUSPENDED = 5;
    public static final int USER_NUM_FLAGS = 6;

    private String name = null;
    private String password = null;
    private int id = 0;
    private Date last_login = null;
    private Date last_enter = null;
    private Date last_exit = null;
    private ArrayList messages = new ArrayList();
    private boolean[] flags = new boolean[USER_NUM_FLAGS];
    
    public UBUser() {
        this.name = "guest";
        this.id = 1; // We reserve ID=1 for guests. Special case.
    }
    
    public UBUser(int id, String name, String password, Date last_login, Date last_enter, Date last_exit, UBMessage[] msg, boolean[] flags) {
        this.name = name;
        this.password = password;
        this.id = id;
        this.last_login = last_login;
        this.last_enter = last_enter;
        this.last_exit = last_exit;
        if (msg != null) {
            for(int j=0;j<msg.length;j++)
                this.messages.add(msg[j]);
        }
        this.flags = flags;
        //loadMessages(this);
        //checkNewMessages(this);
        //checkNewNotifications(this);
    }
    
    public boolean isGuest() {
        return flags[USER_FLAG_GUEST];
    }
    
    public boolean isStudent() {
        return flags[USER_FLAG_STUDENT];
    }
    
    public boolean isAdmin() {
        return flags[USER_FLAG_ADMIN];
    }
    
    public void grantAdmin() {
        flags[USER_FLAG_ADMIN] = true;
    }

    public void revokeAdmin() {
        flags[USER_FLAG_ADMIN] = false;
    }
    
    public int getId() {
        return id;
    }
    
    // Overwriting this function to only compare whether they have the same ID.
    public boolean equals(Object o) {
        return (this.id == ((UBUser)o).getId());
    }
}