-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperator.java
74 lines (61 loc) · 1.93 KB
/
Operator.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
package question;
public class Operator {
private int ID;
private double talkingCharge;
private double messageCost;
private double networkCharge;
private int discountRate;
int operatorTalkingTime;
int operatornOfMessagesSent;
double operatorInternetUsage;
public Operator(int ID, double talkingCharge, double messageCost, double networkCharge, int discountRate) {
this.ID = ID;
this.talkingCharge = talkingCharge;
this.messageCost = messageCost;
this.networkCharge = networkCharge;
this.discountRate = discountRate;
}
double calculateTalkingCost(int minute, Customer customer) {
if(customer.getAge()<18 || customer.getAge()>65) {
return (minute* (customer.getOperator().talkingCharge)) - ((minute*(customer.getOperator().talkingCharge)) * (customer.getOperator().discountRate)/100);
}
else {
return (minute*customer.getOperator().talkingCharge);
}
}
double calculateNetworkCost(double amount) {
return amount * networkCharge;
}
double calculateMessageCost(int quantity, Customer customer, Customer other) {
if(customer.getOperator().ID == other.getOperator().ID) {
return ((quantity*(customer.getOperator().messageCost)) - ((quantity*customer.getOperator().messageCost)*(customer.getOperator().discountRate)/100));
}
else {
return (quantity*customer.getOperator().messageCost);
}
}
public double getTalkingCharge() {
return talkingCharge;
}
public void setTalkingCharge(double talkingCharge) {
this.talkingCharge = talkingCharge;
}
public double getMessageCost() {
return messageCost;
}
public void setMessageCost(double messageCost) {
this.messageCost = messageCost;
}
public double getNetworkCharge() {
return networkCharge;
}
public void setNetworkCharge(double networkCharge) {
this.networkCharge = networkCharge;
}
public int getDiscountRate() {
return discountRate;
}
public void setDiscountRate(int discountRate) {
this.discountRate = discountRate;
}
}