////////////////////////////////////////////////////////////////////// // Project 2 for CS 1704 Spring 2004 // // Programmer: Michael Tuozzo // OS: Windows XP Professional // System: Mobile Pentium 4, 1.2/2.2 GHz, 512 MB Memory // Compiler: Visual C++ 6.0, Service Pack 4 // Last modified: February 18, 2004 // // Purpose // This program maintains a student/multimedia database. Each student // in the database owns a number of multimedia items also stored in // the database. Students and multimedia items can be added and // removed from the database. Print functions are also available. // // On my honor: // // - I have not discussed the C++ language code in my program with // anyone other than my instructor or the teaching assistants // assigned to this course. // // - I have not used C++ language code obtained from another student, // or any other unauthorized source, either modified or unmodified. // // - If any C++ language code or documentation used in my program // was obtained from another source, such as a text book or course // notes, that has been clearly noted with a proper citation in // the comments of my program. // // - I have not designed this program in such a way as to defeat or // interfere with the normal operation of the Curator System. // // Michael Tuozzo /////////////////////////////////////////////////////////////////////// #include #include #include #include #include "mmcontroller.h" using namespace std; ///////////////////////////////////////////////// // Function Name - main // Description - Entry point of the program // // Parameters: // int argc - number of strings separated by white space that // were given at the command line when the program is // called, including the executable // char* argv[] - array of character arrays, contains the strings // that were given at the command line // // Pre: none // Post: program completes // Returns: int (SUCCESS/FAILURE) // // Invokes: mmcontroller object // Calls: mmcontroller::quit() // mmcontroller::print(string) // mmcontroller::print_students() // mmcontroller::print_items() // mmcontroller::insert_item(multimedia) // mmcontroller::insert_student(student) // mmcontroller::delete_student(string) // ///////////////////////////////////////////////// int main(int argc, char**argv) { mmcontroller media_organizer; ifstream commands("commands.data"); assert( commands.is_open() ); //make sure the input file opened string token; while(commands >> token) //continue to input while there are commands in the command file { if(token == "quit"){ //quit the program media_organizer.quit(); return 0; } else if(token == "print"){ commands >> token; if(token == "students") media_organizer.print_students(); //print all students else if(token == "items") media_organizer.print_items(); //print all items else media_organizer.print(token); //print the specified student's info } else if(token == "add"){ commands >> token; commands.ignore(1024, '\n'); if(token == "item"){ //add a new item multimedia tempmedia; if( media_organizer.inputitem(commands, tempmedia) ) media_organizer.insert_item(tempmedia); } else if(token == "student"){ //add a new student student tempstudent; if( media_organizer.inputstudent(commands, tempstudent) ) media_organizer.insert_student(tempstudent); } } else if(token == "delete"){ //remove a student and all associated items from the database commands >> token; media_organizer.delete_student(token); } token = ""; } return 0; }