/** * Takes in an employeeID and logs that employee out of the system. If employee is not in the * loggedOnList it catches the error and prints out that no valid ID was entered. * * @param employeeId * @return */ public boolean logout(int employeeId) { boolean successful = false; try { loggedOnEmployees.removeEmployee(employeeId); successful = true; } catch (NullPointerException e) { System.out.println("Error: employeeID not currently logged on."); } return successful; }
/** * This method takes in an int for employeeID and uses it to remove that specific employee from * the database and the eList. If the ID doesn't exist a message is printed and nothing else * happens. * * @param employeeID */ public void removeEmployee(int employeeID) { if (eList.isEmployee(employeeID) == true) { eList.removeEmployee(employeeID); DBHandler db = DBHandler.getInstance(); db.openConnection("sql595207", "nT1*rF4!"); db.removeEmployee(employeeID); db.closeConnection(); } else { System.out.println("No valid employee ID entered."); } }