home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
- #include <string.h>
-
- class PlaceTime {
- char* place;
- float time;
- public:
- void setPlaceTime(char* p, float t) {
- place=p;
- time=t;
- }
- void setPlace(char* p) {
- place= p;
- }
- char* const& getPlace() const {
- return place;
- }
- float const& getTime() const {
- return (time);
- }
- };
-
- class Parcel {
- PlaceTime origin, destination, nowAt;
- char* identification;
- public:
- Parcel(char* o, char* d, float t, char* i) {
- origin.setPlaceTime(o, t);
- destination.setPlace(d);
- nowAt.setPlaceTime(o, t);
- identification=i;
- }
- void arrivedAt(char* n, float t) {
- if (nowAt.getPlace()!=destination.getPlace()) {
- nowAt.setPlaceTime(n, t);
- }
- }
- PlaceTime const& orig() const {
- return origin;
- }
- PlaceTime const& dest() const {
- return destination;
- }
- PlaceTime const& now() const {
- return nowAt;
- }
- char* const& getID() const {
- return identification;
- }
- int operator==(Parcel const& p) const {
- return!(strcmp(identification, p.identification));
- }
- int operator<(Parcel const& p) const {
- return(strcmp(identification, p.identification)<0);
- }
- };
-
- char* const& key( Parcel const& p) {
- return p.getID();
- }
-