Class StaffManager

java.lang.Object
my.edu.tarc.dco.bookrentalpos.Manager<Staff>
my.edu.tarc.dco.bookrentalpos.StaffManager

public class StaffManager
extends Manager<Staff>
Class to load Staff data for the POS system
Version:
1.0
Author:
Looz
  • Constructor Details

  • Method Details

    • reload

      public void reload()
      Reload the staff database
      Specified by:
      reload in class Manager<Staff>
    • login

      public int login​(String usrName, String pw)
      Used to check if the provided username and password matches database
      Parameters:
      usrName - username of the Staff
      pw - password of the staff in plain text
      Returns:
      staff ID if it matches, returns -1 if nothing matches
    • getById

      public Staff getById​(int staffID)
      Get staff object reference by id
      Specified by:
      getById in class Manager<Staff>
      Parameters:
      staffID - StaffID
      Returns:
      Staff object reference of specified ID, return null if StaffID was not found
    • getByName

      public Staff getByName​(String name)
      Get staff object reference by name
      Specified by:
      getByName in class Manager<Staff>
      Parameters:
      name - staff username
      Returns:
      Staff object reference of specified ID, return null if StaffID was not found
    • getCache

      public Staff[] getCache()
      This function return a copy of the staff list loaded from the database
      Specified by:
      getCache in class Manager<Staff>
      Returns:
      an array of Staff, use StaffManager.getStaffCount() to get the number of entry
      See Also:
      getStaffCount()
    • getLogOnStaff

      public Staff getLogOnStaff()
      Returns:
      staff that is log on using login() function
    • add

      public boolean add​(Staff stf)
      Register a new staff into database
      Specified by:
      add in class Manager<Staff>
      Parameters:
      stf - Staff object without ID
      Returns:
      true if registration was successful, false if same staff name existed
      See Also:
      Staff(java.lang.String, java.lang.String)
    • update

      public boolean update​(Staff stf)
      Update staff information to database
      Specified by:
      update in class Manager<Staff>
      Parameters:
      stf - Staff object, expecting Staff object reference instead of new Staff object
      Returns:
      true if staff info was updated successfully
    • remove

      public boolean remove​(Staff staff)
      Remove staff from the database
      NOTE: The removed staff will not appear in other table as well
      Specified by:
      remove in class Manager<Staff>
      Parameters:
      staff - int
      Returns:
      true if staff was removed successfully
    • logOut

      public void logOut()
      Set logOnStaff to null
      See Also:
      logOnStaff
    • getStaffCount

      public int getStaffCount()
      Returns:
      amount of staff loaded from database