//-------------------------------------------------------- // SPECIFICATION FILE (phonebk.h) // This module exports a PhoneBook ADT //-------------------------------------------------------- #ifndef phonebk_h #define phonebk_h #include "bool.h" const int MAX_ENTRIES = 100; typedef char String20[21]; typedef char String60[61]; struct NameType { String20 first; String20 last; }; struct AddressType { String20 city; String60 address; }; struct PhoneNumType { int areaCode; // Range: 0..999 int prefix; // Range: 0..999 int lastDigs; // Range: 0..9999 }; class PhoneBook { // ABSTRACTLY: a table relating nammes and spouseNames to numbers // and addresses. public: PhoneBook(); // MODIFIES: self // POST: self is the empty table void AddPhone(PhoneNumType number, NameType name, NameType spouseName, AddressType address, Boolean& opSuccessful); // MODIFIES: opSuccessful // POST: opSuccessful == (self not full && number not in self) // && opSuccessful --> number, name, etc. added to self // NOTE: one phone may have two persons listed: name and sposeName void DelPhone(PhoneNumType number, Boolean& opSuccessful); // MODIFIES: opSuccessful // POST: opSuccessful == (number is in self) // && opSuccessful --> self's record for number has been removed void LookupByName(NameType name, Boolean& found, PhoneNumType& number, AddressType& address) const; // MODIFIES: found, number, address // POST: found == (there is an entry for name in self, perhaps as a spouse) // && found --> number and address are from the record associated with name // in self. #include "phonebk.pri" }; #endif