-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportService.java
More file actions
37 lines (32 loc) · 1.3 KB
/
ReportService.java
File metadata and controls
37 lines (32 loc) · 1.3 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
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ReportService {
private EmployeeManager manager;
public ReportService(EmployeeManager manager) {
this.manager = manager;
}
public void payByDivision() {
Map<String, Double> divisionPay = new HashMap<>();
for (FullTimeEmployee emp : manager.getEmployees()) {
divisionPay.put(emp.division, divisionPay.getOrDefault(emp.division, 0.0) + emp.getSalary());
}
for (String division : divisionPay.keySet()) {
System.out.println("Division: " + division + " | Total Pay: $" + divisionPay.get(division));
}
}
public void payByJobTitle() {
Map<String, Double> titlePay = new HashMap<>();
for (FullTimeEmployee emp : manager.getEmployees()) {
titlePay.put(emp.jobTitle, titlePay.getOrDefault(emp.jobTitle, 0.0) + emp.getSalary());
}
for (String title : titlePay.keySet()) {
System.out.println("Job Title: " + title + " | Total Pay: $" + titlePay.get(title));
}
}
public void viewPayHistory(FullTimeEmployee emp) {
for (PayStatement pay : emp.getPayStatementHistory()) {
System.out.println("Date: " + pay.getDate() + " | Amount: $" + pay.getAmount());
}
}
}