Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2db0ce5446
Fetching contributors…

Cannot retrieve contributors at this time

file 66 lines (53 sloc) 1.238 kb
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#include "passenger.h"
Passenger::Passenger(int from_, int to_): from(from_), to(to_) {
total += 1;
timeWait = 0;
timeMove = 0;
}

int Passenger::Total() {
return total;
}

int Passenger::MaxWaitTime() {
return maxWaitTime;
}

int Passenger::MinWaitTime() {
if (minWaitTime == INT_MAX) return -1;
return minWaitTime;
}

int Passenger::AverWaitTime() {
if(total == 0) return 0;
else return totalWaitTime / total;
}

int Passenger::MaxDuration() {
return maxDuration;
}

int Passenger::MinDuration() {
if(minDuration == INT_MAX) return -1;
else return minDuration;
}

int Passenger::AverDuration() {
if(nCompleteDuration == 0) return 0;
else return totalDuration / nCompleteDuration;
}

int Passenger::Get_from() {
  return from;
}

int Passenger::Get_to() {
  return to;
}

void Passenger::Wait(int t) {
totalWaitTime += t;
timeWait += t;
minWaitTime = std::min(minWaitTime, timeWait);
maxWaitTime = std::max(maxWaitTime, timeWait);
}

void Passenger::Move(int t) {
timeMove += 1;
}

void Passenger::Arrive() {
int duration = timeMove + timeWait;

totalDuration += duration;
nCompleteDuration += 1;
minDuration = std::min(minDuration, duration);
maxDuration = std::max(maxDuration, duration);
}
Something went wrong with that request. Please try again.