wm: java

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

View raw version
package Bookproj;

import java.time.LocalDateTime;

public class BasicUser {
    public boolean Active = false;
    protected Role role;
    protected String Username;
    protected int ID;
    protected LocalDateTime RegTime;
    /* we will use isEmpty, even if it's not init-ed */
    private String Reserved = new String();

    public BasicUser(Role r, String u, int id, LocalDateTime rt) {
        this.role = r;
        this.Username = u;
        this.ID = id;
        this.RegTime = rt;
    }

    Role getRole() {
        return this.role;
    }

    String getUsername() {
        return this.Username;
    }

    int getID() {
        return this.ID;
    }

    void clearReserved() {
        this.Reserved = "";
    }

    void setReserved(String isbn) {
        /* ensure he has no books */
        if (!this.getReserved().isEmpty() && !isbn.equals(""))
            throw new IllegalStateException("User already has a book!");

        this.Reserved = isbn;
    }

    String getReserved() {
        return this.Reserved;
    }

    LocalDateTime getRegTime() {
        return this.RegTime;
    }
}