// This program will store a large database of the students and their items. #include #include #include #include using std::ifstream; using std::ofstream; using std::string; using std::getline; using std::ws; #include "DataBase.h" int main() { // Used to input and output the commands and output respectivly ifstream inCommand; ofstream outFile; inCommand.open("commands.data"); outFile.open("output.data"); // If the input and output files fail, then the program will not continue assert(!inCommand.fail()); assert(!outFile.fail()); string Input; DataBase DataList; bool WhileCheck; string namein, typein, authorin, ownerin, pricein, availabilityin; string phonein, emailin, streetnumberin, aptnumberin, cityin, statein, zipcodein, otherin; // Keeps on looping until it reaches the end of the file or Input = quit while(inCommand && Input != "quit") { if(inCommand.peek() == '\n') inCommand.ignore(1, '\n'); else { inCommand >> Input; // Prints out the Students or item if(Input == "print") { outFile << Input << ' '; inCommand >> Input; outFile << Input << endl; if(Input == "students") DataList.PrintAllStudents(outFile); else if(Input == "items") DataList.PrintAllItems(outFile); else DataList.PrintEmail(outFile, Input); } // Adds a student or item if(Input == "add") { outFile << Input << ' '; inCommand >> Input; outFile << Input << endl; WhileCheck = true; if(Input == "item") { namein = "none"; typein = "none"; authorin = "none"; ownerin = "none"; pricein = "none"; availabilityin = "none"; while(WhileCheck != false) { getline(inCommand, Input, '\n'); if(Input == "@Item:") getline(inCommand, namein, '\n'); else if(Input == "@Media Type:") getline(inCommand, typein, '\n'); else if(Input == "@by:") getline(inCommand, authorin, '\n'); else if(Input == "@Owner:") getline(inCommand, ownerin, '\n'); else if(Input == "@Price:") getline(inCommand, pricein, '\n'); else if(Input == "@Availability:") getline(inCommand, availabilityin, '\n'); else if(Input == "@@" && ownerin != "none") { DataList.AddItem(outFile, namein, typein, authorin, ownerin, pricein, availabilityin); WhileCheck = false; } else if(Input == "@@" && ownerin == "none") WhileCheck = false; else inCommand >> ws; } } if(Input == "student") { namein = "none"; phonein = "none"; emailin = "none"; streetnumberin = "none"; aptnumberin = "none"; cityin = "none"; statein = "none"; zipcodein = "none"; otherin = "none"; while(WhileCheck != false) { getline(inCommand, Input, '\n'); if(Input == "@Name:") getline(inCommand, namein, '\n'); else if(Input == "@Phone Number:") getline(inCommand, phonein, '\n'); else if(Input == "@E-mail:") getline(inCommand, emailin, '\n'); else if(Input == "@Address Line 1:") getline(inCommand, streetnumberin, '\n'); else if(Input == "@Address Line 2:") getline(inCommand, aptnumberin, '\n'); else if(Input == "@City:") getline(inCommand, cityin, '\n'); else if(Input == "@State:") getline(inCommand, statein, '\n'); else if(Input == "@Zipcode:") getline(inCommand, zipcodein, '\n'); else if(Input == "@Other:") getline(inCommand, otherin, '\n'); else if(Input == "@@" && emailin != "none") { DataList.AddStudent(outFile, namein, phonein, emailin, streetnumberin, aptnumberin, cityin, statein, zipcodein, otherin); WhileCheck = false; } else if(Input == "@@" && emailin == "none") WhileCheck = false; else inCommand >> ws; } } } // Deletes the student and item if(Input == "delete") { outFile << Input << ' '; inCommand >> Input; outFile << Input << endl; DataList.DeleteEmail(outFile, Input); } if(Input == "quit") { outFile << Input; } } inCommand >> ws; } inCommand.close(); outFile.close(); return 0; } /* On my honor: - I have no 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 textbook 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. Enoch K. Pak */