Skip to content
Snippets Groups Projects
Commit 0eb20858 authored by Rafi's avatar Rafi
Browse files

Implemented functions and signatures from Staff UML diagram.

parent 45c6fa78
No related branches found
No related tags found
3 merge requests!3Added 'mysql-connector-java-8.0.28.jar.' This is the connector/j driver that...,!2Added 'mysql-connector-java-8.0.28.jar.' This is the connector/j driver that...,!1Added 'mysql-connector-java-8.0.28.jar.' This is the connector/j driver that...
package com.example.schedulerapp;
import java.util.ArrayList;
import java.util.List;
public class Staff {
/*
Test to see if this works with 'final' key word.
*/
private final List<Employee> allStaff = new ArrayList<>();
public void addEmployee(String name, String position, float wage, String number, boolean manager, Shift[] availability) {
int ID = 0;
if (allStaff.size() > 0) {
ID = allStaff.get(allStaff.size() - 1).getID() + 1;
}
Employee newEmployee = new Employee(name, position, wage, number, manager, availability, ID);
this.allStaff.add(newEmployee);
}
public void removeEmployee(int ID) {
for (Employee employee: allStaff) {
if (employee.getID() == ID) {
allStaff.remove(employee);
break;
}
}
}
/*
Not finished. Names are not unique. Although, getting employees by name is convenient.
*/
public void removeEmployee(String name) {
for (Employee employee: allStaff) {
if (employee.getName().equals(name)) {
allStaff.remove(employee);
break;
}
}
}
public Employee getEmployee(int ID) {
for (Employee employee: allStaff) {
if (employee.getID() == ID) {
return employee;
}
}
return null;
}
/*
Not finished. Names are not unique. Although, getting employees by name is convenient.
*/
public Employee getEmployee(String name) {
for (Employee employee: allStaff) {
if (employee.getName().equals(name)) {
return employee;
}
}
return null;
}
public List<Employee> getAllStaff() {
return allStaff;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment