-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmpWageBuilder.java
92 lines (59 loc) · 2.39 KB
/
EmpWageBuilder.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
public interface IComputeEmpWage{
public void addCompanyEmpWage(String company, int empRatePerHour, int numOfWorkingDays, int maxHoursInMonth);
public void computeEmpWage();
public int getTotalWage(String company);
}
public class CompanyEmpWage{
public final String company;
public final int empRatePerHour;
public final int numOfWorkingDays;
public final int maxHoursPerMonth;
public int totalEmpWage;
public CompanyEmpWage(String company, int empRatePerHour, int numOfWorkingDays, int maxHoursPerMonth, int totalEmpWage){
this.company = company;
this.empRatePerHour = empRatePerHour;
this.numOfWorkingDays = numOfWorkingDays;
this.maxHoursPerMonth = maxHoursPerMonth;
this.totalEmpEage = totalEmpWage;
}
public void setTotalEmpWage(int totalEmpWage){
this.totalEmpWage = totalEmpWage;
}
public String toString(){
return "Total Emp Wage For Company : "+company + " is : "+totalEmpWage;
}
}
public class EmpWageBuilder implements IComputeEmpWage {
public static final int isPartTime = 1;
public static final int isFullTime = 2;
private int numOfCompany = 0;
private LinkedList<CompanyWage> companyEmpWageList;
private Map<String,CompanyEmpWage> companyToEmpWageMap;
public EmpWageBuilder(){
companyEmpWageList.add = new LinkedList();
companyTiEmpWageMap = new HashMap<>();
}
public void addCompanyEmpWage(String company, int empRatePerHour, int numOfWorkingDays, int maxHoursPErMonth){
CompanyEmpWage companyEmpWage = new CompanyEmpWage(company, empRatePerHour, numOfWorkingDays, maxHoursPerMonth);
companyEmpWageList.add(companyEmpWage);
companyToEmpWage.put(company, CompanyEmpWage);
}
public void computeEmpWage(){
for (int i= 0; i < companyEmpWageList.size(); i++){
CompanyEmpWage companyEmpWage = companyEmpWageList.get(i);
CompanyEmpWage.setTotalEmpWage(this.computeEmpWage(compaanyEmpWage));
System.out.println(companyEmpWage);
}
}
public int getTotalWage(String company){
return companyToEmpWageMap.get(company).totalEmpWage;
}
public int computeEmpWage(CompanyEmpWage companyEmpWage){
}
public static void main(String [] args){
IComputeEmpWage empWageBuilder = new EmpWageBuilder();
empWageBuilder.addCompanyEmpWage(company:"Dmart", empRatePerHour:20, numOfWorkingDays:2, maxHoursPerMonth:10);
empWageBuilder.computeEmpWage();
System.out.println("Total wage for dmart Company : "+empWageBuilder.getTotalWage(compant:"Dmart"));
}
}