-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsiteManager.java
More file actions
48 lines (39 loc) · 1.56 KB
/
siteManager.java
File metadata and controls
48 lines (39 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.codedifferently;
import java.util.ArrayList;
// Manager role that tracks on-site location and a list of assigned employees.
public class siteManager extends Person{
// Current location text for this manager.
private String location;
// Employees currently assigned to this manager/site.
private ArrayList<Employee> employeesonsite;
// Counter used when printing summary details.
private int totalemployees;
// Initializes manager profile, location, and an empty employee list.
public siteManager(int id, String firstname, String lastname, String email, String location){
super(id, firstname, lastname, email);
this.location=location;
this.employeesonsite= new ArrayList<>();
this.totalemployees=totalemployees;
}
public void setLocation(String location) {
this.location = location;
}
public String getLocation() {
return location;
}
// Adds an employee object to the manager's on-site roster.
public void addemployee(Employee employee){
employeesonsite.add(employee);
}
@Override
// Prints each employee summary and manager details, then returns a total count label.
public String getSummary() {
for (Employee e : employeesonsite) {
++totalemployees;
System.out.println("\n" + e.getSummary());
System.out.println("[Site Manager]" + getFirstname() + " " + getLastname()
+ "\n" + " Location: " + location);
}
return "Total employees" + " " + totalemployees;
}
}