48 #define PAUSE_TIME 15 //time (in minutes) a bus waits before going in the opposite direction.
62 std::list<AGBus>::iterator it1 =
buses.begin();
63 std::list<AGBus>::iterator it2 =
revBuses.begin();
65 std::list<std::pair<int, std::string> > drivingBuses1, drivingBuses2;
68 if (it1->getDeparture() > it2->getDeparture()) {
69 if (drivingBuses2.size() == 0) {
70 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
71 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
72 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
75 it2->setName(drivingBuses2.front().second);
76 drivingBuses2.pop_front();
78 drivingBuses1.push_back(make_pair(
getReady(it2->getDeparture()), it2->getName()));
81 if (drivingBuses1.size() == 0) {
82 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
83 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
84 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
87 it1->setName(drivingBuses1.front().second);
88 drivingBuses1.pop_front();
90 drivingBuses2.push_back(make_pair(
getReady(it1->getDeparture()), it1->getName()));
94 if (it1 !=
buses.end()) {
95 if (drivingBuses1.size() == 0) {
97 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
100 it1->setName(drivingBuses1.front().second);
101 drivingBuses1.pop_front();
106 if (drivingBuses2.size() == 0) {
108 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
111 it2->setName(drivingBuses2.front().second);
112 drivingBuses2.pop_front();
121 std::ostringstream os;
136 return static_cast<int>(
buses.size());
164 std::list<AGBus>::iterator it;
165 std::cout <<
"\n ----------- BUS LINE " <<
lineNumber <<
" PRINTING -------------\n" << std::endl;
166 std::cout <<
"\n -------------------------- First way ---------------------------\n" << std::endl;
167 for (it =
buses.begin(); it !=
buses.end(); ++it) {
170 std::cout <<
"\n -------------------------- Second way --------------------------\n" << std::endl;
174 std::cout <<
"\n ----------------------------------------------------------------\n" << std::endl;