// ferrysimevent.cpp // ---------------------------------------------------------------------- // // CSE 143 // Homework 4 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 21 Jul 2000, Ken Yasuhara #include #include "ferrysimevent.h" FerrySimEvent::FerrySimEvent() { time = -1; ID = CAR_BOARDING; carPtr = NULL; ferryPtr = NULL; } FerrySimEvent::FerrySimEvent(const int newTime, const EventID newID, Car *newCarPtr, Ferry *newFerryPtr) { assert(newTime >= 0); assert(newCarPtr != NULL || newFerryPtr != NULL); time = newTime; ID = newID; carPtr = newCarPtr; ferryPtr = newFerryPtr; } int FerrySimEvent::compare(const FerrySimEvent &otherEvent) const { if (getTime() < otherEvent.getTime()) { return -1; } else if (getTime() > otherEvent.getTime()) { return 1; } // times equal; tiebreak by ID if (getID() < otherEvent.getID()) { return -1; } else if (getID() > otherEvent.getID()) { return 1; } // times and IDs must match return 0; }