41 #define PAUSE_TIME 15 //time (in minutes) a bus waits before going in the opposite direction. 55 std::list<AGBus>::iterator it1 =
buses.begin();
56 std::list<AGBus>::iterator it2 =
revBuses.begin();
58 std::list<std::pair<int, std::string> > drivingBuses1, drivingBuses2;
61 if (it1->getDeparture() > it2->getDeparture()) {
62 if (drivingBuses2.size() == 0) {
63 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
64 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
65 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
68 it2->setName(drivingBuses2.front().second);
69 drivingBuses2.pop_front();
71 drivingBuses1.push_back(make_pair(
getReady(it2->getDeparture()), it2->getName()));
74 if (drivingBuses1.size() == 0) {
75 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
76 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
77 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
80 it1->setName(drivingBuses1.front().second);
81 drivingBuses1.pop_front();
83 drivingBuses2.push_back(make_pair(
getReady(it1->getDeparture()), it1->getName()));
87 if (it1 !=
buses.end()) {
88 if (drivingBuses1.size() == 0) {
90 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
93 it1->setName(drivingBuses1.front().second);
94 drivingBuses1.pop_front();
99 if (drivingBuses2.size() == 0) {
101 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
104 it2->setName(drivingBuses2.front().second);
105 drivingBuses2.pop_front();
114 std::ostringstream os;
129 return static_cast<int>(
buses.size());
155 std::list<AGBus>::iterator it;
156 std::cout <<
"\n ----------- BUS LINE " <<
lineNumber <<
" PRINTING -------------\n" << std::endl;
157 std::cout <<
"\n -------------------------- First way ---------------------------\n" << std::endl;
158 for (it =
buses.begin(); it !=
buses.end(); ++it) {
161 std::cout <<
"\n -------------------------- Second way --------------------------\n" << std::endl;
165 std::cout <<
"\n ----------------------------------------------------------------\n" << std::endl;
void generateBuses(int start, int stop, int rate)
void setMaxTripTime(int time)
std::list< AGPosition > stations
A location in the 2D plane freely positioned on a street.
std::list< AGPosition > revStations
void locateRevStation(AGPosition pos)
void locateStation(AGPosition pos)
std::list< AGBus > revBuses
void addMinutes(int min)
addition of minutes to the current moment
void addSeconds(int sec)
addition of seconds to the current moment
int getTime()
: returns the number of seconds from the beginning of the first day of simulation this includes ...