// car.h // ---------------------------------------------------------------------- // // CSE 143 // Homework 4 // http://www.cs.washington.edu/education/courses/143/00su/homework/ // 21 Jul 2000, Ken Yasuhara #ifndef _CAR_H_ #define _CAR_H_ #include // doesn't include driver; see getPassengerCount() below const int MAX_PASSENGERS_PER_CAR = 3; class Car { public: Car(const int newArrivalTime, const int newPassengerCount); // returns # passengers in this car; doesn't include driver, i.e. // # people in car is getPassengerCount() + 1 int getPassengerCount() const { return passengerCount; } // returns time at which this car arrived, i.e. entered the // ticketing queue int getArrivalTime() const { return arrivalTime; } // marks this car as having been issued a ticket; called when car // leaves ticketing queue; must not call more than once on any // given car void issueTicket(); // returns true iff this car has been ticketed bool isTicketed() const { return ticketed; } // marks this car as having been boarded, i.e. loaded onto the // ferry currently docked; must be ticketed first, must not call // more than once on any given car void board(); // returns true iff this car has been loaded onto a ferry bool isBoarded() const { return boarded; } // returns int uniquely identifying this car; mostly for testing int getInstanceID() const { return instanceID; } // writes car data to cout; for testing void print() const; private: // disallow default construction, copy construction, assignment, // not only in client code, but also inside methods Car() { assert(false); } Car(const Car &otherCar) { assert(false); } Car &operator=(const Car &otherCar) { assert(false); return *this; } // // internal representation // int passengerCount; int arrivalTime; bool ticketed; // These two are bool boarded; // initially false. // assigned at construction int instanceID; // class static member; number of instances constructed // Don't worry if you don't understand this. static int instanceCount; }; #endif // _CAR_H_