-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.java
More file actions
34 lines (29 loc) · 1.01 KB
/
Event.java
File metadata and controls
34 lines (29 loc) · 1.01 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
abstract class Event implements Comparable<Event> {
protected final double eventTime;
protected final Customer customer;
private static final double EPSILON = 1E-14;
public abstract Pair<Maybe<Event>, Pair<Shop, Stats>> next(Shop shop, Stats stats);
public boolean same_id(Event other) {
return this.customer.same_id(other.customer);
}
public Event(Customer customer, double eventTime) {
this.eventTime = eventTime;
this.customer = customer;
}
public int compareTo(Event event) {
double d = this.eventTime - event.eventTime;
if (d < -1.0 * EPSILON) {
return -1;
} else if (d > EPSILON) {
return 1;
} else {
if (this.customer.compareTo(event.customer) == -1) {
return -1;
} else if (this.customer.compareTo(event.customer) == 1) {
return 1;
}
}
return 1;
}
public abstract String toString();
}