wm: java

ref: c38e733d9de9f416af3f1e629bc351c4723e2425
dir: /Bookproj/Admin.java/

View raw version
package Bookproj;

import java.time.LocalDateTime;
import java.util.TreeMap;

public class Admin extends BasicUser {
    private String Password;

    Admin(String user)
    {
        super(Role.Admin, user, (int)(Math.random()*100), LocalDateTime.now());

    }
    Admin(String user, String Pass)
    {
        /* maybe check if password is too easy? */
        super(Role.Admin, user, (int)(Math.random()*100), LocalDateTime.now());
        this.setPassword(Pass);
    }

    boolean checkPass(String pass) {
        if (this.Password.equals(pass))
            return true;
        else
            return false;
    }

    /* passwords should be unchangeable... for now */
    protected void setPassword(String pass) {
        this.Password = pass;
    }

    TreeMap<AdminAttr, String> toMap() {
        TreeMap<AdminAttr, String> temp = new TreeMap<AdminAttr, String>();

        temp.put(AdminAttr.Username, getUsername());
        temp.put(AdminAttr.role, getRole().toString());
        temp.put(AdminAttr.Reserved, getReserved());
        temp.put(AdminAttr.ID, Integer.toString(getID()));
        temp.put(AdminAttr.RegTime, getRegTime().toString());
        /*  temp.put(Bookproj.AdminAttr.Password, this.Password); secrect secrect secrect */
        temp.put(AdminAttr.Active, Boolean.toString(this.Active));

        return temp;
    }
}