-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRide.java
More file actions
48 lines (37 loc) · 1.05 KB
/
Copy pathRide.java
File metadata and controls
48 lines (37 loc) · 1.05 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
class Ride {
// Ride is our object represent taxi object
// heap index is used as a link between RBT and min Heap
// element found in RBT in O(log(n)) time can be accessed in O(1) time using heapIndex
int rideNumber;
int rideCost;
int tripDuration;
int heapIndex;
int color;
Ride parent;
Ride left;
Ride right;
// default constructor
public Ride(){
this.rideNumber = 0;
this.rideCost = 0;
this.tripDuration = 0;
this.heapIndex = -1;
}
// parameterized constructor
public Ride(int rideNumber, int rideCost, int tripDuration){
this.rideNumber = rideNumber;
this.rideCost = rideCost;
this.tripDuration = tripDuration;
this.heapIndex = -1;
}
// setter methods
public void setIndex(int heapIndex) {
this.heapIndex = heapIndex;
}
public void setRideCost(int rideCost) {
this.rideCost = rideCost;
}
public void setTripDuration(int tripDuration) {
this.tripDuration = tripDuration;
}
}