-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUC7EmpWageRefactor.java
54 lines (34 loc) · 988 Bytes
/
UC7EmpWageRefactor.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
class UC7Refactor{
public static final int isFullTime = 1;
public static final int isPartTime = 2;
public static final int empRatePerHr = 20;
public static final int numOfWorkingDays = 2;
public static final int maxHrsInMonth = 10;
public void computeWage(){
int empHrs = 0;
int totalEmpHrs = 0;
int totalWorkingDays = 0;
while (totalEmpHrs <= maxHrsInMonth && totalWorkingDays < numOfWorkingDays){
totalWorkingDays++;
int empCheck = (int) Math.floor(Math.random()*10)%3;
switch (empCheck){
case isFullTime :
empHrs = 8;
break;
case isPartTime :
empHrs = 4;
break;
default :
empHrs = 0;
}
totalEmpHrs += empHrs;
System.out.println("Day : "+totalWorkingDays + "Emp Hrs : "+empHrs);
}
int totalEmpWage = totalEmpHrs * empRatePerHr;
System.out.println("Total Emp Wage : "+totalEmpWage);
}
public static void main(String [] args){
UC7Refactor u7 = new UC7Refactor();
u7.computeWage();
}
}