// 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. // // Programmer: Dominic Bagley // OS: Windows 2000 Professional // System: Pentium III 500, 256 MB Memory // Compiler: C++ Dot Net 2003 // Last modified: Feb 23, 2004 // // Purpose // This program tracks a list of trades made by students // #include #include #include #include #include "DataBase.h" using namespace std; void Exit(ifstream&, ofstream&); void IgnoreBlank(ifstream& IN); int main(){ ifstream IN; ofstream OUT; DataBase D; string Comm, Comm2; //open file streams IN.open("commands.data"); OUT.open("output.data"); assert(!IN.fail()); assert(!OUT.fail()); //load students and items D.Load(); //IgnoreBlank(IN); IN >> Comm; //while data is in the infile while(IN){ //cout << Comm << endl; if(Comm == "add"){ IN >> Comm2; if(Comm2 == "item"){ OUT << "add item\n"; D.AddItem(IN, OUT); } else{ OUT << "add student\n"; D.AddStudent(IN, OUT); } } else if(Comm == "print"){ IN >> Comm2; //OUT << Comm << "1 "; if(Comm2 == "students"){ OUT << "print students"; D.PrintStudents(OUT); OUT << endl; } else if(Comm2 == "items"){ OUT << "print items\n"; D.PrintItems(OUT); //OUT << endl; } else{ D.PrintStudent(IN, OUT, Comm2); //OUT << endl << endl; } } else if(Comm == "quit"){ OUT << "quit\n"; Exit(IN, OUT); } else{ //OUT << " deleting "; D.DeleteStudent(IN, OUT); } //IgnoreBlank(IN); IN >> Comm; } return 0; } //////////////////////////////////////////////////////////////// // // // Parameters: // // // Pre: // // Post: // // Returns: Describe what value the function returns, if any. // // Called by: // Calls: // void Exit(ifstream& inFile, ofstream& outFile){ inFile.close(); outFile.close(); } void IgnoreBlank(ifstream& IN){ if(IN.peek() == '\n'){ IN.ignore(200, '\n'); IgnoreBlank(IN); } }