47 #define PAUSE_TIME 15 //time (in minutes) a bus waits before going in the opposite direction. 61 std::list<AGBus>::iterator it1 =
buses.begin();
62 std::list<AGBus>::iterator it2 =
revBuses.begin();
64 std::list<std::pair<int, std::string> > drivingBuses1, drivingBuses2;
67 if (it1->getDeparture() > it2->getDeparture()) {
68 if (drivingBuses2.size() == 0) {
69 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
70 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
71 drivingBuses2.push_front(make_pair(it2->getDeparture(),
createName()));
74 it2->setName(drivingBuses2.front().second);
75 drivingBuses2.pop_front();
77 drivingBuses1.push_back(make_pair(
getReady(it2->getDeparture()), it2->getName()));
80 if (drivingBuses1.size() == 0) {
81 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
82 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
83 drivingBuses1.push_front(make_pair(it1->getDeparture(),
createName()));
86 it1->setName(drivingBuses1.front().second);
87 drivingBuses1.pop_front();
89 drivingBuses2.push_back(make_pair(
getReady(it1->getDeparture()), it1->getName()));
93 if (it1 !=
buses.end()) {
94 if (drivingBuses1.size() == 0) {
96 }
else if (drivingBuses1.front().first > it1->getDeparture()) {
99 it1->setName(drivingBuses1.front().second);
100 drivingBuses1.pop_front();
105 if (drivingBuses2.size() == 0) {
107 }
else if (drivingBuses2.front().first > it2->getDeparture()) {
110 it2->setName(drivingBuses2.front().second);
111 drivingBuses2.pop_front();
120 std::ostringstream os;
135 return static_cast<int>(
buses.size());
161 std::list<AGBus>::iterator it;
162 std::cout <<
"\n ----------- BUS LINE " <<
lineNumber <<
" PRINTING -------------\n" << std::endl;
163 std::cout <<
"\n -------------------------- First way ---------------------------\n" << std::endl;
164 for (it =
buses.begin(); it !=
buses.end(); ++it) {
167 std::cout <<
"\n -------------------------- Second way --------------------------\n" << std::endl;
171 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 ...