// CSE143 Sp01 Homework 2 Sample Solution // placelist.h - interface to class PlaceList, // a list of place name and location pairs // HP 4/01 #ifndef _PLACELIST_H_ #define _PLACELIST_H_ #include using namespace std; #include "location.h" const int MAX_PLACES = 30; // maximum # places in the list class PlaceList { // a list of place and location pairs public: // Construct an empty PlaceList PlaceList(); // Add place with given name and coordinates to this PlaceList // Assumption: this PlaceList is not full void add(double x, double y, string name); // = "this PlaceList contains a place with the specified name bool contains(string name); // = Location of the place with the specified name; if the name is not // found, the result is a Location whose coordinates are not defined. Location locationOf(string name); private: struct Place { // list entry for one place: string name; // place name Location loc; // place location }; Place list[MAX_PLACES]; // information about places is stored int size; // in list[0..size-1] // = index of first Place containing specified name, or current size if // the name is not found int indexOf(string name); }; #endif