//************************************************************************************************************ // Michael Rose // // Microsoft Visual Studio .NET 2003 // Windows XP PRO // MediaDatabase // This is a database of students and media types owned by those students // // 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 Rose //************************************************************************************************************ #include #include #include #include #include"database.h" using namespace std; int main() { // Open file streams ifstream commands("commands.data"); ofstream out("output.data"); // Declare and initialize variables database organizer; // variable for the database class string command, // what to do to the array parameter, // what is being added or printed file, // what is to be added stream, // string stream email; // the email of the dleted student bool result = false; // the result of the boolean functions // Primary read commands >> ws >> command; while(commands) { if(command == "delete") { // Read in the person to be deleted commands >> ws >> email; // Echo the command to the output file out << command << '\t' << email << endl; // Delete the entry and print out the result result = organizer.delete_entry(email); if(result == true) { out << "Success" << endl; } else { out << "Failure" << endl; } } else if(command == "add") { // Read in what to add commands >> ws >> parameter; // Echo to the output file out << command << '\t' << parameter << endl; if(parameter == "student") { // Add the student result = organizer.add_student(commands); if(result == true) { out << "Success" << endl; } else { out << "Failure" << endl; } } else if(parameter == "item") { // Add the item result = organizer.add_media(commands); if(result == true) { out << "Success" << endl; } else { out << "Failure" << endl; } } else { assert((parameter == "item") || (parameter == "student")); } } else if(command == "print") { // Read in the way to print commands >> ws >> parameter; // Echo command out << command << '\t' << parameter << endl; organizer.print(parameter, out); } else if(command == "quit") { out << command; // Close the filestreams out.close(); commands.close(); return 0; } else { assert((command == "delete") || (command == "add") || (command == "print") || (command == "quit")); } // Secondary read commands >> command >> ws; } assert(false); return 0; }