class Profile { friend ostream& operator<<(ostream &out, Profile p); friend istream& operator>>(istream &in, Profile &p); public: Profile(); Profile(const Profile &p); string getUserName(); void setUserName(string userName); void setMeasures(vector measures); void setNextPtr(Profile *nextPtr); Profile *getNextPtr(); double similarity(Profile p); void enterData(); void print(); static const int nMeasures = 21; private: string userName; vector measures; Profile *nextPtr; }; // Profile Class /*------------------------------------------------------------------------*/ Profile::Profile() -- Default constructor Profile::Profile(const Profile &p) -- Copy constructor, uses the Profile p to construct the object. Accessor and observer methods: string Profile::getUserName() void Profile::setUserName(string userName) void Profile::setMeasures(vector measures) void Profile::setNextPtr(Profile *nextPtr) Profile *Profile::getNextPtr() double Profile::similarity(Profile p) -- Given a Profile p, computes the similarity between p and the object using the 21 measures. void Profile::enterData() -- Takes input from the keyboard for the userName and each of the measures. void Profile::print() -- Prints the object's data members in a "pretty" format. Overloaded stream insertion/extraction operators primarily for file I/O: ostream& operator<<(ostream &out, Profile p) istream& operator>>(istream &in, Profile &p) /*=========================================================================*/ class ProfileList { public: ProfileList(); bool empty(); void save(string filename); void load(string filename); void add(string filename); void add(Profile profile); Profile *findMostSimilar(Profile profile); void clear(); ~ProfileList(); private: Profile *profiles, *last; }; // ProfileList Class /*------------------------------------------------------------------------*/ ProfileList::ProfileList() -- Default constructor. bool ProfileList::empty() -- Returns true if the object is empty; return false otherwise. void ProfileList::save(string filename) -- Writes the Profile objects stored in the list to the file named filename. void ProfileList::load(string filename) -- Loads and creates a linked list of Profile objects, anchored to the profiles private data member, using the data stored in the file named filename. void ProfileList::add(string filename) -- Adds the profiles stored in the file named filename to the end of the linked list, pointed to by the last private data member. void ProfileList::add(Profile profile) -- Adds the profile object to the end of the linked list. Profile *ProfileList::findMostSimilar(Profile profile) -- Scans the profiles stored in the linked list to find the most similar to the parameter profile. Returns a pointer to the most similar Profile object in the list. void ProfileList::clear() -- Destroys all of the Profile objects stored in the linked list. ProfileList::~ProfileList() -- Destroys all of the Profile objects stored in the linked list. /*=========================================================================*/ class ProfilerApp { public: void processCommands(); private: void printMenu(); void addProfile(); void addProfilesFromFile(); void saveProfiles(); void loadProfiles(); void classifyProfile(); void classifyProfilesFromFile(); void clearProfiles(); ProfileList profiles; }; // ProfilerApp /*------------------------------------------------------------------------*/ void ProfilerApp::processCommands() -- Main event loop that prompts for commands and executes them. void ProfilerApp::printMenu() -- Prints the menu options. void ProfilerApp::addProfile() -- Lets the user add a single profile. void ProfilerApp::addProfilesFromFile() -- Lets the user provide a filename and add profiles to the end of ProfileList. void ProfilerApp::saveProfiles() -- Lets the user save the current ProfileList to a file. void ProfilerApp::loadProfiles() -- Lets the user load profiles from a file. void ProfilerApp::classifyProfile() -- Lets the user enter a profile and finds the most similar in ProfileList, indicating whether the same user produced both profiles. void ProfilerApp::classifyProfilesFromFile() -- Lets the user enter a filename and finds the most similar to each in the ProfileList, indicating whether the same users produced both profiles. void ProfilerApp::clearProfiles() -- Lets the user clear the ProfileList. /*=========================================================================*/ int main() { ProfilerApp profiler; profiler.processCommands(); return 0; } // main