I have to complete a project about employees and their jobs.
The requirements include:
Setting multiple jobs for an employee
etc. etc.
Two of the obvious classes I have for this are the Employee and Job class which hold individual employees and work like this:
private Employee[] e = new Employee[1000];
private Job[] j = new Job[1000];
e[0] = new Employee("Arthur");
e[1] = new Employee("Jane");
j[0] = new Job("Cooking");
j[1] = new Job("Cleaning");
This allows me to manage behaviour of individual employees and assign whichever jobs to whichever employee I like. But I also have another class called EmployeesOnSystem and JobsOnSystem where, the total list of employees/jobs are kept in a List and can be returned with a method, so I have to register the above employees/jobs first like so...
private allEmployees = new EmployeesOnSystem();
private allJobs = new JobsOnSystem();
for (int i = 0; i < e.length; i++) { //register each employee
allEmployees.register(e[i].getName);
}
for (int i = 0; i < j.length; i++) { //register each job
allJobs.register(e[j].getName);
}
It would be simple to store a list of all employees with the original employee class and all jobs within the original job class but since I've heard each class should be only dependent on itself and only have methods/behaviours that are totally relevant to it.
Would it be a bad idea to have a separate class to hold all employees/all jobs on system or is it better to do it like this?