// this file contains the interface for commandClass, which stores a list of students and // their media #ifndef COMMAND_H #define COMMAND_H #include "studentClass.h" #include "mediaClass.h" const int MAX_MEDIA = 100; // max number of items that can be stored const int MAX_STUDENTS = 100; // max number of students that can be stored class commandClass { private: int numStudents, // valid length of studentArray numItems; // valid length of itemArray studentClass studentArray[MAX_STUDENTS]; // stores students mediaClass itemArray[MAX_MEDIA]; // stores items virtual bool found( const string ) const; // returns whether a student is in the array // PARAMETERS: // const string MATCH email address of student to find // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // bool whether student was found // CALLS // none // CALLED BY // commandClass:: add // remove // printSpecific virtual bool found( const mediaClass ) const; // returns whether media is in the array // PARAMETERS: // const mediaClass MEDIA media to be found // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // bool whether item was found // CALLS // none // CALLED BY // none public: // MUTATORS: bool remove( const string ); // removes a student and all associated media // PARAMETERS: // const string EMAIL email address of student to remove // PRE-CONDITIONS // none // POST-CONDITIONS // matching student and all his media has been removed // RETURNS // bool whether student was found and removed // CALLS // commandClass::found // CALLED BY // main virtual bool add( const mediaClass& ); // adds an item // PARAMETERS: // const mediaclass ITEM item to add // PRE-CONDITIONS // none // POST-CONDITIONS // item has been added // RETURNS // bool whether add was successful // CALLS // commandClass::found // CALLED BY // main virtual bool add( const studentClass& ); // adds a student // PARAMETERS: // const mediaclass STUDENT item to add // PRE-CONDITIONS // none // POST-CONDITIONS // student has been added if not duplicate // RETURNS // bool whether add was successful // CALLS // commandClass::found // CALLED BY // main // ACCESSORS: string printStudents() const; // prints the student list // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string the student list // CALLS // studentClass:: << // CALLED BY // main string printItems() const; // prints the item list // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string the item list // CALLS // mediaClass:: << // CALLED BY // main string printSpecific( const string ) const; // prints the student data and all his media // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // none // RETURNS // string the student's info and a list of his media // CALLS // studentClass:: << // mediaClass:: << // print // CALLED BY // main // CONSTRUCTORS: commandClass(); // default constructor // PARAMETERS: // none // PRE-CONDITIONS // none // POST-CONDITIONS // object is initialized to blank // RETURNS // none // CALLS // none // CALLED BY // none commandClass( const char*, const char* ); // constructer that takes two filenames // PARAMETERS: // const char* STUDENT_FILE filename of file containing student data // const char* ITEM_FILE filename of file containing item data // PRE-CONDITIONS // none // POST-CONDITIONS // student list and item list have been read in from the given files // RETURNS // none // CALLS // commandClass:: add // CALLED BY // main }; #endif