/* 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 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. Tony Pitale */ // Tony Pitale VS.NET 2003 Windows XP Pro 2/19/04 9044-14007 #include #include #include #include #include "array.h" using namespace std; //Functions int main(int argc, char* argv[]) { ifstream inFile1; ifstream inFile2; string tempname; string tempphone; string tempemail; string tempstreet; string tempapt; string tempcity; string tempstate; string tempzip; string tempother; // used to temporarily store data before passing into function string tempitem; string temptype; string tempby; string tempowner; string tempprice; string tempavail; // used to temporarily store data before passing into function string outerCheck; string middleCheck; string innerCheck; // used to check for command names char ch; // random character to eat @ symbols array holdAll(inFile1, inFile2); // array class passed infile declarations to open holdAll.inputStudent(inFile1, inFile2); // function call to input student data, calls inputItems from inside ifstream inFile("commands.data"); // command input file inFile >> outerCheck; // outer check i.e. add, print, delete, quit assert(outerCheck == "add" || outerCheck == "print" || outerCheck == "delete" || outerCheck == "quit"); while(inFile) { inFile >> ws; if(outerCheck == "add") { inFile >> middleCheck; inFile >> ws; assert(middleCheck == "student" || middleCheck == "item"); if(middleCheck == "item") { tempitem = "empty"; temptype = "empty"; tempby = "empty"; tempowner = "empty"; tempprice = "empty"; tempavail = "empty"; if(inFile.peek() == '@') { inFile.get(ch); getline(inFile, innerCheck, '\n'); while(innerCheck != "@") { if(innerCheck == "Item:") { getline(inFile, tempitem, '\n'); inFile >> ws; } else if(innerCheck == "Media Type:") { inFile >> temptype; inFile >> ws; } else if(innerCheck == "by:") { getline(inFile, tempby, '\n'); inFile >> ws; } else if(innerCheck == "Owner:") { getline(inFile, tempowner, '\n'); inFile >> ws; } else if(innerCheck == "Price:") { getline(inFile, tempprice, '\n'); inFile >> ws; } else if(innerCheck == "Availability:") { getline(inFile, tempavail, '\n'); inFile >> ws; } inFile >> ws; inFile.get(ch); getline(inFile, innerCheck, '\n'); } holdAll.addItem(tempitem, temptype, tempby, tempowner, tempprice, tempavail); } } else if(middleCheck == "student") { tempname = "empty"; tempphone = "empty"; tempemail = "empty"; tempstreet = "empty"; tempapt = "empty"; tempcity = "empty"; tempstate = "empty"; tempzip = "empty"; tempother = "empty"; if(inFile.peek() == '@') { inFile.get(ch); getline(inFile, innerCheck, '\n'); while(innerCheck != "@") { if(innerCheck == "Name:") { getline(inFile, tempname, '\n'); inFile >> ws; } else if(innerCheck == "Phone Number:") { getline(inFile, tempphone, '\n'); inFile >> ws; } else if(innerCheck == "E-mail:") { getline(inFile, tempemail, '\n'); inFile >> ws; } else if(innerCheck == "Address Line 1:") { getline(inFile, tempstreet, '\n'); inFile >> ws; } else if(innerCheck == "Address Line 2:") { getline(inFile, tempapt, '\n'); inFile >> ws; } else if(innerCheck == "City:") { getline(inFile, tempcity, '\n'); inFile >> ws; } else if(innerCheck == "State:") { getline(inFile, tempstate, '\n'); inFile >> ws; } else if(innerCheck == "Zipcode:") { getline(inFile, tempzip, '\n'); inFile >> ws; } else if(innerCheck == "Other:") { getline(inFile, tempother, '\n'); inFile >> ws; } inFile >> ws; inFile.get(ch); getline(inFile, innerCheck, '\n'); } holdAll.addStudent(tempname, tempphone, tempemail, tempstreet, tempapt, tempcity, tempstate, tempzip, tempother); } } } else if(outerCheck == "print") { inFile >> ws; inFile >> middleCheck; inFile >> ws; if(middleCheck == "students") { holdAll.printStudents(); } else if(middleCheck == "items") { holdAll.printItems(); } else { tempemail = middleCheck; holdAll.printIndivid(tempemail); } } else if(outerCheck == "delete") { inFile >> ws; inFile >> tempemail; inFile >> ws; holdAll.deleteIndivid(tempemail); } else if(outerCheck == "quit") { ofstream outFile("output.data", ios::app); outFile << "quit"; outFile.close(); break; } inFile >> ws; outerCheck = "nothing"; inFile >> outerCheck; middleCheck = "nothing"; innerCheck = "nothing"; } inFile.close(); }