-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomer.java
50 lines (39 loc) · 1.26 KB
/
Customer.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
package cs2030.simulator;
import java.util.function.Supplier;
import java.util.Optional;
class Customer implements Comparable<Customer> {
private final int customerId;
private final Supplier<Double> serviceTime;
private final double arrivalTime;
private final boolean isGreedy;
private Optional<Double> serviceTimeCache;
Customer(int customerId, Supplier<Double> serviceTime, double arrivalTime, boolean isGreedy) {
this.customerId = customerId;
this.serviceTime = serviceTime;
this.arrivalTime = arrivalTime;
this.isGreedy = isGreedy;
this.serviceTimeCache = Optional.<Double>empty();
}
int getCustomerId() {
return this.customerId;
}
Double getServiceTime() {
Double serviceTime = this.serviceTimeCache.orElseGet(this.serviceTime);
this.serviceTimeCache = Optional.<Double>of(serviceTime);
return serviceTime;
}
double getArrivalTime() {
return this.arrivalTime;
}
boolean isGreedy() {
return this.isGreedy;
}
@Override
public String toString() {
return String.format("%d%s", this.customerId, isGreedy ? "(greedy)" : "");
}
@Override
public int compareTo(Customer c) {
return 0;
}
}