#include "stdstuff.h" // #include "Date.h" moved to Customer.h #include "Customer.h" class CustomerDB { private: Customer *ci; // dynamically allocated array of customer information int numCusts; // the number of customers currently in the database bool walkInProgress; int walkPosition; // position of last value returned // private method to delete database; used by destructor and assignment void deleteDB(); // private method to copy database; used by copy constructor and assignment void copyDB(const CustomerDB &otherCustDB); public: // Your methods go here. Remember to describe each method (i.e. comments!) // and use "const" where appropriate. // the constructor creates an empty database CustomerDB(); // copy constructor CustomerDB(const CustomerDB &otherCustDB); // destructor ~CustomerDB(); // assignment CustomerDB& operator=(const CustomerDB &otherCustDB); // returns the number of customers in the database int getNumCusts() const; // add a new customer to the database; returns true if successful, false otherwise // (database full or customer already exists) bool add(const Customer &newCust); // remove a customer from the database; returns true if successful, false otherwise (customer // does not exist) bool remove(int id); // prints the full customer database (or a note if the database is empty) // Customers are printed one per line, with 2 decimals for the total. void print() const; // change the customer number of an existing customer; returns true if successful, // false otherwise (customer does not exist, or new customer id in use) bool changeID(int id, int nid); // change the customer total of an existing customer; returns true if successful, // false otherwise (customer does not exist) bool changeTotal(int id, double ntotal); // move the purchase date by the number of days given; returns true if successful, // false otherwise (customer does not exist) bool moveDate(int id, int days); // append the given String2002 to the customer name; returns true if successful, // false otherwise (customer does not exist) bool appendName(int id, const String2002 &add); // returns the lowest customer ID of all customers // (returns -1 if there are no customers in the database) int getLowestID() const; // returns the highest total of all customers // (returns -1 if there are no customers in the database) double getBestTotal() const; // prints (to cout) the earliest purchase date of all customers // (prints 1 1 1900 if there are no customers in the database) void outputFirstDate() const; // returns the customer name that's first in case insensitive alphabetical order // (returns "" if there are no customers in the database) String2002 getFirstName() const; // These two methods make it possible to "walk through" the customers in a // customer database. The customers may be returned in any order. There is no // guarantee that they will be returned in numerical order, in the order in // which they were entered, or any other particular order. "startWalk" may // be called at any time. If returns true on success (customer obtained) and // false on failure (database empty). If it returns true, it "returns" a customer // by reference. "continueWalk" may only be called if // 1/. the database has not been modified since a walk was // begun by calling startWalk AND // 2/. the last call to startWalk or ContinueWalk returned true // If these conditions are not met, "continueWalk" quits. // It returns true on success (customer obtained) and false on // failure (no more customers). If it returns true, it "returns" a customer // by reference. bool startWalk (Customer ¤tCustomer); bool continueWalk (Customer ¤tCustomer); };