40 #define PAUSE_TIME 15 //time (in minutes) a bus waits before going in the opposite direction.
54 std::list<AGBus>::iterator it1 =
buses.begin();
55 std::list<AGBus>::iterator it2 =
revBuses.begin();
57 std::list<std::pair<int, std::string> > drivingBuses1, drivingBuses2;
60 if (it1->getDeparture() > it2->getDeparture()) {
61 if (drivingBuses2.size() == 0) {
62 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
63 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
64 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
67 it2->setName(drivingBuses2.front().second);
68 drivingBuses2.pop_front();
70 drivingBuses1.push_back(make_pair(
getReady(it2->getDeparture()), it2->getName()));
73 if (drivingBuses1.size() == 0) {
74 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
75 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
76 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
79 it1->setName(drivingBuses1.front().second);
80 drivingBuses1.pop_front();
82 drivingBuses2.push_back(make_pair(
getReady(it1->getDeparture()), it1->getName()));
86 if (it1 !=
buses.end()) {
87 if (drivingBuses1.size() == 0) {
89 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
92 it1->setName(drivingBuses1.front().second);
93 drivingBuses1.pop_front();
98 if (drivingBuses2.size() == 0) {
100 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
103 it2->setName(drivingBuses2.front().second);
104 drivingBuses2.pop_front();
113 std::ostringstream os;
128 return static_cast<int>(
buses.size());
154 std::list<AGBus>::iterator it;
155 std::cout <<
"\n ----------- BUS LINE " <<
lineNumber <<
" PRINTING -------------\n" << std::endl;
156 std::cout <<
"\n -------------------------- First way ---------------------------\n" << std::endl;
157 for (it =
buses.begin(); it !=
buses.end(); ++it) {
160 std::cout <<
"\n -------------------------- Second way --------------------------\n" << std::endl;
164 std::cout <<
"\n ----------------------------------------------------------------\n" << std::endl;