public static Event warErrupt(Employee e, Company c) throws EmployeeNotExist { List<Employee> emList = c.getEmployeeList(); int number = emList.size() * 2 / 3; for (int i = 0; i < number; i++) { int n = new Random().nextInt(emList.size()); Utilities.getInstance().unassignComputerToEmployee(c, c.getEmployeeList().get(n)); c.removeEmployee(c.getEmployeeList().get(n)); } return Event.WAR_ERUPTS; }
public static Event companyBurnt(Employee e, Company c) throws EmployeeNotExist { List<Employee> emList = c.getEmployeeList(); for (Employee employee : emList) { if (!employee.isLoyal()) { Utilities.getInstance().unassignComputerToEmployee(c, employee); c.removeEmployee(employee); c.decreaseMoney(c.getMoney() * 2 / 3); } } return Event.COMPANY_IS_BURNT_DOWN_BY_ANONYMOUS; }
public static Event projectStolen(Employee e, Company c) { try { Project p = e.getWorkingProject(); if (p != null) { c.cancelProject(p); Utilities.getInstance().unassignComputerToEmployee(c, e); c.removeEmployee(e); return Event.PROJECT_IS_STOLEN_BY_EMPLOYEE; } else { return Event.NO_EVENT; } } catch (EmployeeNotExist ex) { } finally { return Event.NO_EVENT; } }
public static Event killDeveloper(Employee e, Company c) { try { if (c.getEmployeeList().size() >= 2) { int num = new Random().nextInt(c.getEmployeeList().size()); Utilities.getInstance().unassignComputerToEmployee(c, c.getEmployeeList().get(num)); c.removeEmployee(c.getEmployeeList().get(num)); num = new Random().nextInt(c.getEmployeeList().size()); c.removeEmployee(c.getEmployeeList().get(num)); return Event.DEVELOPER_KILLS_ANOTHER_DEVELOPER; } } catch (EmployeeNotExist ex) { } finally { return Event.NO_EVENT; } }
public static Event redundancies(Employee e, Company c) throws EmployeeNotExist { Project p = e.getWorkingProject(); List<Employee> removeEmp = new ArrayList(); if (p != null) { Map<Skill, Employee> skill = p.getSkill_employeeMap(); for (Skill sk : skill.keySet()) { if (skill.get(sk) != null && skill.get(sk).equals(e)) { c.addEmployeeToRemoveList(e); } else if (skill.get(sk) != null) { skill.get(sk).sad(); } } for (Employee employee : removeEmp) { Utilities.getInstance().unassignComputerToEmployee(c, employee); c.removeEmployee(employee); } return Event.REDUNDANCIES; } return Event.NO_EVENT; }