// Project 2 for CS 1704 Spring 2004 // // Programmer: Mike D'Haem // OS: Windows Xp Pro // System: AMD 2200+ 1024 // Compiler: Visual C++ .net // Last modified: Today // // Purpose: // A multimedia Organizer #include "Contain.h" int main() { ifstream Commands("commands.data"); Container ObjectA;//Creates the class objects ObjectA.AddStudent();//reads in Student File ObjectA.AddItem();//Reads in Items File while (Commands)//While loop that reads in commands and calls the coinspoing function. { string Temp, Command; Commands >> Command >> ws; if(Command == "delete") { Commands >> Temp >> ws ; ObjectA.Delete(Temp); } if(Command == "print") { assert(Command == "print");//ASSERT NUMBER 1 Commands >> Temp >> ws; if(Temp == "students") ObjectA.PrintStudents(); else if(Temp == "items") ObjectA.PrintItems(); else ObjectA.Print(Temp); } if(Command == "add") { Commands >> Temp >> ws; assert(Commands != "sdf ");//ASSERT NUMBER 3 if(Temp == "item") { string Poo, Name="None", Media="None", Owner="None", by="None", Avail="None"; int Dollar=-1, Cents=-1; while(Poo != "@@")//Reads in all the cool stuff { if(Commands.peek()== '@') { getline(Commands, Poo, '\n'); if(Poo=="@Item:") { getline(Commands, Name, '\n'); } else if(Poo=="@Media Type:") { getline(Commands, Media, '\n'); } else if(Poo=="@by:") { getline(Commands, by, '\n'); } else if(Poo=="@Owner:") { getline(Commands, Owner, '\n'); } else if(Poo=="@Price:") { Commands.ignore(1); Commands >> Dollar; Commands.ignore(1); Commands >> Cents; } else if(Poo=="@Availability:") { getline(Commands, Avail, '\n'); } else if(Poo=="@@") { ObjectA.AddItem2(Name, Media, by, Owner, Dollar, Cents, Avail); } else cout << "Error" << endl; } else Commands.ignore(INT_MAX,'\n'); } } if(Temp == "student")//adds a student by calling a class construtor { string Name="None", Phone="None", Mail="None", Add1="None", Add2="None", City="None", State="None", Crack, Other="None"; int Zip=-1; while(Crack != "@@") { if(Commands.peek()=='@') { getline(Commands, Crack, '\n'); if(Crack=="@Name:") { getline(Commands, Name, '\n'); } else if(Crack=="@Phone Number:") { getline(Commands, Phone, '\n'); } else if(Crack=="@E-mail:") { getline(Commands, Mail, '\n'); } else if(Crack=="@Address Line 1:") { getline(Commands, Add1, '\n'); } else if(Crack =="@Address Line 2:") { getline(Commands, Add2, '\n'); } else if(Crack =="@City:") { getline(Commands, City, '\n'); } else if(Crack == "@State:") { getline(Commands, State, '\n'); } else if(Crack == "@Zipcode:") { Commands >> Zip >> ws; } else if(Crack == "@Other:") { getline(Commands, Other, '\n'); } else if(Crack == "@@") { ObjectA.AddStudent2(Name, Phone, Mail, Add1, Add2, City, State, Zip, Other); } } else Commands.ignore(INT_MAX, '\n'); } } } if(Command == "quit") { ObjectA.Quit(); Commands.close; } } assert(true); // ASSERT NUMBER 2 return 0; }