-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrival_Event.cpp
30 lines (26 loc) · 991 Bytes
/
Arrival_Event.cpp
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
#include "Arrival_Event.h"
// Default constructor initializing arrival time to zero
ArrivalEvent::ArrivalEvent() : Event() {
arrivalHour = 0;
arrivalMinute = 0;
}
// Accessor for arrival hour
int ArrivalEvent::getArrivalHour() const {
return arrivalHour;
}
// Accessor for arrival minute
int ArrivalEvent::getArrivalMinute() const {
return arrivalMinute;
}
// Executes the arrival event based on passenger type and arrival time
void ArrivalEvent::Excute(const Passenger& P, Queue& Q, Event& E, PriorityQueue& PQ, Clock& c) {
const string& eventType = E.getEventType();
const string& passType = P.getPassengerType();
int hour = c.getHour();
int minute = c.getMinute();
if (eventType != "L" && passType == "W" && arrivalHour == hour && arrivalMinute == minute) {
Q.enqueue(P.getId());
} else if (eventType != "L" && passType != "W" && arrivalHour == hour && arrivalMinute == minute) {
PQ.enqueue(P.getId(), P.getPriority());
}
}