-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBus.cpp
30 lines (25 loc) · 921 Bytes
/
Bus.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 "Bus.h"
// Constructor
Bus::Bus() : timeStep(0), status(' '), direction(""), counter(0) {}
// Setters
void Bus::setTimeStep(int x) { timeStep = x; }
void Bus::setStatus(char x) { status = x; }
void Bus::setDirection(const std::string& x) { direction = x; }
void Bus::setCounter(int x) { counter = x; }
// Getters
int Bus::getTimeStep() const { return timeStep; }
char Bus::getStatus() const { return status; }
std::string Bus::getDirection() const { return direction; }
int Bus::getCounter() const { return counter; }
// Other functionalities
void Bus::addPassenger(Passenger* passenger, int p) {
onBoard.enqueue(passenger, p);
}
void Bus::removePassenger() {
if (!onBoard.isEmpty()) {
Passenger* p = onBoard.frontElement();
onBoard.dequeue();
// Be careful with memory management. Ensure that you manage the memory for Passenger objects correctly.
delete p;
}
}