-
Notifications
You must be signed in to change notification settings - Fork 0
/
Service.java
137 lines (111 loc) · 3.67 KB
/
Service.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package service.model;
public class Service {
public static final double BASE_RATE = 80.00;
public static final double TENTH_DISCOUNT = 0.50;
public static final double SUB_DISCOUNT = 0.9;
private HouseSize size;
public String address;
public int numOfFloor;
public int serviceCount;
public boolean isSub;
public int hourWash;
public int hourClean;
public int hourPaint;
public int numOfPet;
public void setSize(HouseSize size) {
this.size = size;
}
public HouseSize getSize() {
return size;
}
public String getAddress() {
return address;
}
public void setAddress(String address) throws IllegalArgumentException {
if (address == null) {
throw new IllegalArgumentException("The address is null");
}
this.address = address;
}
public boolean isSub() {
return isSub;
}
public void setSub(boolean sub) {
isSub = sub;
}
public int getHourClean() {
return hourClean;
}
public void setHourClean(int hourClean) {
this.hourClean = hourClean;
}
public void setHourWash(int hourWash) {
this.hourWash = hourWash;
}
public int getHourWash() {
return hourWash;
}
public int getHourPaint() {
return hourPaint;
}
public void setHourPaint(int hourPaint) {
this.hourPaint = hourPaint;
}
public int getNumOfFloor() {
return numOfFloor;
}
public void setNumOfFloor(int numOfFloor) throws IllegalArgumentException {
if (numOfFloor < 0) {
throw new IllegalArgumentException("The floor number should not be negative integer ");
}
if (numOfFloor > 5) {
throw new IllegalArgumentException("The maximum number of floors " +
"that the company can work with is 5,It should not be possible to create " +
"a window cleaning service for a property with more than 3 floors" +
"please contact the company to verify");
}
this.numOfFloor = numOfFloor;
}
public int getNumOfPet() {
return numOfPet;
}
public void setNumOfPet(int numOfPet) throws IllegalArgumentException {
if (numOfPet < 0) {
throw new IllegalArgumentException("The pet number should not be negative integer ");
}
this.numOfPet = numOfPet;
}
public int getServiceCount() {
return serviceCount;
}
public void setServiceCount(int serviceCount) throws IllegalArgumentException {
if (serviceCount < 0) {
throw new IllegalArgumentException("The service count should not be negative integer ");
}
this.serviceCount = serviceCount;
}
public Service(HouseSize size, String address, int numOfFloor, int numOfPet, int serviceCount, boolean isSub) {
this.size = size;
this.numOfFloor = numOfFloor;
this.numOfPet = numOfPet;
this.address = address;
this.serviceCount = serviceCount;
this.isSub = isSub;
}
public double disCountPrice(double curPrice) {
//System.out.println("before discount: " + curPrice);
if (serviceCount % 10 == 0 && serviceCount > 0) {
// System.out.println("10% : " + curPrice * TENTH_DISCOUNT);
return curPrice * TENTH_DISCOUNT;
}
if (isSub) {
//System.out.println("Monthly : " + curPrice * SUB_DISCOUNT);
return curPrice * SUB_DISCOUNT;
}
//System.out.println("No discount : " + curPrice * SUB_DISCOUNT);
return curPrice;
}
public double serviceFee() {
return 0;
}
}