-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem3.java
More file actions
62 lines (58 loc) · 1.07 KB
/
Problem3.java
File metadata and controls
62 lines (58 loc) · 1.07 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
49
50
51
52
53
54
55
56
57
58
59
60
61
abstract class Worker{
private int ID;
Worker(){
ID = -1;
}
Worker(int ID){
this.ID = ID;
}
Worker(Worker w){
ID = w.ID;
}
abstract double computeWages();
}
class MonthlyWorker extends Worker{
private int numOfDays;
MonthlyWorker(){
super();
numOfDays = -1;
}
MonthlyWorker(int numOfDays, int ID){
super(ID);
this.numOfDays = numOfDays;
}
MonthlyWorker(MonthlyWorker mw){
super(mw);
numOfDays = mw.numOfDays;
}
double computeWages(){
return 200*numOfDays;
}
}
class DailyWorker extends Worker{
private int numOfHours;
DailyWorker(){
super();
numOfHours = -1;
}
DailyWorker(int numOfHours, int ID){
super(ID);
this.numOfHours = numOfHours;
}
DailyWorker(DailyWorker dw){
super(dw);
numOfHours = dw.numOfHours;
}
double computeWages(){
return 20*numOfHours;
}
}
class Problem3{
public static void main(String[] args){
MonthlyWorker r = new MonthlyWorker();
MonthlyWorker r1 = new MonthlyWorker(23,123);
DailyWorker s = new DailyWorker();
System.out.println(r1.computeWages());
System.out.println(r.computeWages());
}
}