// ============================================================================ // **************************************************************************** // 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. // // Brandon Paul Herron // // ============================================================================ // **************************************************************************** // // Project 2 for CS 1044 Summer Session II 2003 Multimedia Organizer // // // Programmer: Brandon P. Herron // OS: Windows XP Pro, Service Pack 1 // System: AMD 1.4 Thunderbird, 512mb RAM // Compiler: Visual Studio.NET 2002 // Last modified: Not sure... modified all the time because its a piece of crap. // // Lab OS: Windows 2000? // Lab System: ? // Lab Compiler: Visual Studio.NET 2003 // Last Modified: ? // // // ============================================================================ // **************************************************************************** // // 1704 Website http://courses.cs.vt.edu/~cs1704/summer2003/ // #include // for input / output streams #include // for formatting manipulators #include // for file streams #include // for string variables #include // for the C standard library for "atoi" function #include // for stringstream #include // for assert statements using namespace std; // setw, setprecision, int DEBUG_FLAG=0; // Starting class StudenInfo definition class StudentInfo { friend class Array_Controller; // Sets Array_Controller class as a friend public: StudentInfo(string aStudentName = "Nothing", string aStudentPhoneNumber = "(000) 000-0000", string aStudentEmailAddress = "Nothing", string aStudentStreetLine1 = "Nothing", string aStudentStreetLine2 = "Nothing", string aStudentCity = "Nothing", string aStudentState = "Nothing", string aStudentZip = "00000", string aOtherInfo = "Nothing", bool aStudentInfoPresent = false); // Default constructor for StudentInfo bool GetStudentInfoPresent(); // Scans Student_Array to find empty locations string GetStudentName(); // Returns StudentName string GetStudentPhoneNumber(); // Returns StudentPhoneNumber string GetStudentEmailAddress(); // Returns StudentEmailAddress string GetStudentStreetLine1(); // Returns StudentLine1 string GetStudentStreetLine2(); // Returns StudentLine2 string GetStudentCity(); // Returns StudentCity string GetStudentState(); // Returns StudentState string GetStudentZip(); // Returns StudentZip string GetOtherInfo(); // Returns OtherInfo void PrintStudent(ostream& Out);// prints the information in a student class ~StudentInfo(){} // Default Destructor private: string StudentName; // Variable to hold the students name string StudentPhoneNumber; // Variable to hold the students phone number string StudentEmailAddress; // Variable to hold the students email address string StudentStreetLine1; // Variable to hold the students street string StudentStreetLine2; // Variable to hold the students apt info string StudentCity; // Variable to hold the students city string StudentState; // Variable to hold the students state string StudentZip; // Variable to hold the students zip string OtherInfo; // Variable to hold the students other info bool StudentInfoPresent; // Variable which shows if info is present or not }; // Starting class ItemInfo definition class ItemInfo{ friend class Array_Controller; // Sets Array_Controller class as a friend public: ItemInfo( string aItemName = "Nothing", string aItemType = "Nothing", string aItemAuthor = "Nothing", string aItemOwner = "Nothing", string aItemPrice = "$0.00", string aItemAvailability = "Nothing", bool aItemInfoPresent = false); // default constructor for ItemInfo bool GetItemInfoPresent(); // Scans Item_Array for empty locations string GetItemName(); // Returns ItemName string GetItemType(); // Returns ItemType string GetItemAuthor(); // Returns ItemAuthor string GetItemOwner(); // Returns ItemOwner string GetItemPrice(); // Returns ItemPrice string GetItemAvailability(); // Returns ItemAvailability void PrintItem(ostream& Out); // prints the info in a item class void PrintItem2(ostream& Out); // prints the info in a item class minus the email address ~ItemInfo(){} // Default Destructor for ItemInfo private: string ItemName; // Variable to hold the items name string ItemType; // Variable to hold the items media type string ItemAuthor; // Variable to hold the items author string ItemOwner; // Variable to hold the items owner string ItemPrice; // Variable to hold the items price string ItemAvailability; // Variable to hold the items availability bool ItemInfoPresent; // Variable which shows if info is present or not }; // class Array_Controller { public: Array_Controller(); // default constructor for Array_Controller int searchStudent_Array(); // searches the Student_Array for the next open array location int searchItem_Array(); // searches the Item_Array for the next open array location void InputStudentInfo(ifstream& Sin, StudentInfo &s); // inputs the information from the students.data file and places it in the Students_Array void InputItemInfo(ifstream& Iin, ItemInfo &i); // inputs the information from the items.data file and places it in the Item_Array bool ADDStudent(ifstream& InputS); // adds a student from the commands.data to the next available array location in Students_Array bool ADDItem(ifstream& InputI); // adds an item from the commands.data to the next available array location in Items_Array bool ArrayEmailDelete(string DeleteEmailAddress); // Deletes an email address and all associated info from the 2 arrays void printStudentInfo(ofstream& Out, StudentInfo &s); // prints student info void printItemInfo(ofstream& Out, ItemInfo &i); // prints item info bool printEmailAddress(ofstream& Out, StudentInfo &s, ItemInfo &i, string PrintEmail); // printsthe email address if one is matched in the two arrays ~Array_Controller(){} // default destructor for Array Controller private: static const int Size = 100; // StudentInfo Student_Array[Size]; // Array of StudentInfo Size 100 ItemInfo Item_Array[Size]; // Array of ItemInfo Size 100 ofstream Out; // }; //////////////////////////////////////////////////////////////// StudentInfo // This is the constructor for the StudentInfo class. // // Parameters:string aStudentName, string aStudentPhoneNumber, // string aStudentEmailAddress, string aStudentStreetLine1, // string aStudentStreetLine2, string aStudentCity, // string aStudentState, string aStudentZip, // string aOtherInfo, bool aStudentInfoPresent // // Pre: The class StudentInfo has to have been created. // // Post: All parameters are set to null. // // Returns: Nothing // // Called by: The class // Calls: None. // StudentInfo::StudentInfo(string aStudentName, string aStudentPhoneNumber, string aStudentEmailAddress, string aStudentStreetLine1, string aStudentStreetLine2, string aStudentCity, string aStudentState, string aStudentZip, string aOtherInfo, bool aStudentInfoPresent) { StudentName = aStudentName; StudentPhoneNumber = aStudentPhoneNumber; StudentEmailAddress = aStudentEmailAddress; StudentStreetLine1 = aStudentStreetLine1; StudentStreetLine2 = aStudentStreetLine2; StudentCity = aStudentCity; StudentState = aStudentState; StudentZip = aStudentZip; OtherInfo = aOtherInfo; StudentInfoPresent = aStudentInfoPresent; } //////////////////////////////////////////////////////////////// ItemInfo // This is the constructor for the ItemInfo class. // // Parameters: string aItemName, string aItemType, string aItemAuthor, // string aItemOwner, string aItemPrice, string aItemAvailability, // bool aItemInfoPresent // // Pre: The class ItemInfo has to have been created // // Post: All parameters are set to null. // // Returns: Nothing // // Called by: The class // Calls: None. // ItemInfo::ItemInfo( string aItemName, string aItemType, string aItemAuthor, string aItemOwner, string aItemPrice, string aItemAvailability, bool aItemInfoPresent) { ItemName = aItemName; ItemType = aItemType; ItemAuthor = aItemAuthor; ItemOwner = aItemOwner; ItemPrice = aItemPrice; ItemAvailability = aItemAvailability; ItemInfoPresent = aItemInfoPresent; } //////////////////////////////////////////////////////////////// Array_Controller // This is the constructor for the Array_Controller class. It opens the input // file for the Students_Array and Items_Array and files the arrays. // // Parameters: None // // Pre: The class Array_Controller has to have been created // // Post: All parameters are set to null. // // Returns: Nothing // // Called by: The class // Calls: InputStudentInfo() // InputInfoInfo() // Array_Controller::Array_Controller() { ifstream In_Student("students.data"); int IndexS = 0; while (In_Student) { InputStudentInfo(In_Student, Student_Array[IndexS]); IndexS++; In_Student.ignore(255, '\n'); } In_Student.close(); ifstream In_Item("items.data"); int IndexI = 0; while (In_Item){ InputItemInfo(In_Item, Item_Array[IndexI]); IndexI++; In_Item.ignore(255, '\n'); } In_Item.close(); } //////////////////////////////////////////////////////////////// InputStudentInfo // The method that reads in from the input file and inserts the gathered info // into the Student_Array. // // Parameters: ifstream& Sin, StudentInfo &s // // Pre: The class StudentInfo has to have been created along with Array_Controller // // Post: The array is filled with input data appropriately // // Returns: Nothing // // Called by: Array_Controller() // Calls: None. // void Array_Controller::InputStudentInfo(ifstream& Sin, StudentInfo &s) { string Command = "Nothing"; getline ( Sin, Command ); while ( Sin ){ if (Command == "@Name:") { getline ( Sin, s.StudentName ); } else if (Command == "@E-mail:") { getline ( Sin, s.StudentEmailAddress ); s.StudentInfoPresent = true; } else if (Command == "@Address Line 1:") { getline ( Sin, s.StudentStreetLine1 ); } else if (Command == "@Address Line 2:") { getline ( Sin, s.StudentStreetLine2 ); } else if (Command == "@Phone Number:") { getline ( Sin, s.StudentPhoneNumber ); } else if (Command == "@City:") { getline ( Sin, s.StudentCity ); } else if (Command == "@State:") { getline ( Sin, s.StudentState ); } else if (Command == "@Zipcode:") { getline ( Sin, s.StudentZip ); } else if (Command == "@Other:") { getline ( Sin, s.OtherInfo ); } else if (Command == "@@") { return; } else { if (DEBUG_FLAG == 1) { int temp; cout << "*************" << endl << Command << endl << "****************" << endl; // cin >> temp; } cout << "> Error Reading students Input file" << endl; } getline ( Sin, Command ); } return; } //////////////////////////////////////////////////////////////// InputItemInfo // The method that reads in from the input file and inserts the gathered info // into the Item_Array. // // Parameters: ifstream& Sin, ItemInfo &i // // Pre: The class ItemInfo has to have been created along with Array_Controller // // Post: The array is filled with input data appropriately // // Returns: Nothing // // Called by: Array_Controller() // Calls: None. // void Array_Controller::InputItemInfo(ifstream& Iin, ItemInfo &i) { string Command = "Nothing"; getline ( Iin, Command ); while ( Iin ){ if (Command == "@Item:") { getline ( Iin, i.ItemName ); } else if (Command == "@Media Type:") { getline ( Iin, i.ItemType ); } else if (Command == "@by:") { getline ( Iin, i.ItemAuthor ); } else if (Command == "@Owner:") { getline ( Iin, i.ItemOwner ); i.ItemInfoPresent= true; } else if (Command == "@Price:") { getline ( Iin, i.ItemPrice ); } else if (Command == "@Availability:") { getline (Iin, i.ItemAvailability); } else if (Command == "@@") { return; } else { if (DEBUG_FLAG == 1) { int temp; cout << "*************" << endl << Command << endl << "****************" << endl; // cin >> temp; } cout << "> Error Reading items Input file" << endl; } getline ( Iin, Command ); } return; } //////////////////////////////////////////////////////////////// AddStudent // The method which Adds a student from the input command file. // must make sure to input to first available array location in Student_Array // // Parameters: ifstream& InputS // // Pre: The class StudentInfo has to have been created along with Array_Controller // // Post: Adds a student to the Student_Array and gives feedback on the // completion of the task. // // Returns: True or False // // Called by: Main // Calls: InputStudentInfo() // searchStudent_Array() // bool Array_Controller::ADDStudent(ifstream& InputS) { bool addstudentsuccess = false; int Location = searchStudent_Array(); if (Location != -1) { InputStudentInfo(InputS, Student_Array[Location]); addstudentsuccess = true; } return addstudentsuccess; } //////////////////////////////////////////////////////////////// AddItem // The method which Adds a student from the input command file. // must make sure to input to first available array location in Item_Array // // Parameters: ifstream& InputI // // Pre: The class ItemInfo has to have been created along with Array_controller // // Post: Adds a student to the Item_Array and gives feedback on the // completion of the task. // // Returns: True or False // // Called by: Main // Calls: InputItemInfo() // searchItem_Array() // bool Array_Controller::ADDItem(ifstream& InputI) { bool additemsuccess = false; int Location = searchItem_Array(); if (Location != -1) { InputItemInfo(InputI, Item_Array[Location]); for (int Sindex = 0; Sindex <= 99; Sindex++){ assert (Sindex <= 99); if (Student_Array[Sindex].GetStudentEmailAddress() == Item_Array[Location].GetItemOwner()) { additemsuccess = true; } } if (additemsuccess == false) { Item_Array[Location] = ItemInfo(); } } return additemsuccess; } //////////////////////////////////////////////////////////////// ArrayEmailDelete // // Parameters: string DeleteEmailAddress // // Pre: All classes were initialized properly // // Post: deletes a certain email address in both arrays. // // Returns: delete success // // Called by: Main // Calls: GetStudentEmailAddress() // StudentInfo() -- Constructor for StudentInfo // GetItemOwner() // ItemInfo() // bool Array_Controller::ArrayEmailDelete(string DeleteEmailAddress) { bool deletesuccess = false; for (int Iindex = 0; Iindex <= 99; Iindex++) { if (Item_Array[Iindex].GetItemOwner() == DeleteEmailAddress) { Item_Array[Iindex] = ItemInfo(); deletesuccess = true; } } for (int Eindex = 0; Eindex <= 99; Eindex++) { if (Student_Array[Eindex].GetStudentEmailAddress() == DeleteEmailAddress) { Student_Array[Eindex] = StudentInfo(); deletesuccess = true; } } return deletesuccess; } //////////////////////////////////////////////////////////////// searchStudent_Array // This Method searchs the Student_Array for the first empty array location, // if/when that location is found new inforamtion is added to it. // // Parameters: None // // Pre: The class StudentInfo has to have been created along with Array_Controller // // Post: None // // Returns: the location of a open space in the array or negative 1. // // Called by: ? // Calls: GetStudentInfoPresent() // int Array_Controller::searchStudent_Array(){ for (int index = 0; index <= 99; index++){ assert (index <= 99); if (Student_Array[index].GetStudentInfoPresent() == false){ return index; } } return -1; } //////////////////////////////////////////////////////////////// searchItem_Array // This Method searchs the Item_Array for the first empty array location, // if/when that location is found new inforamtion is added to it. // // Parameters: None // // Pre: The class ItemInfo has to have been created along with Array_Controller // // Post: None // // Returns: the location of a open space in the array or negative 1. // // Called by: ? // Calls: GettemInfoPresent() // int Array_Controller::searchItem_Array(){ for (int index = 0; index <= 99; index++){ assert (index <= 99); if (Item_Array[index].GetItemInfoPresent() == false){ return index; } } return -1; } //////////////////////////////////////////////////////////////// printStudentInfo // This method prints the Student_array into the output file. // // Parameters: ofstream& Out, StudentInfo &s // // Pre: The class StudentInfo has to have been created along with Array_Controller // // Post: None // // Returns: Nothing // // Called by: Main // Calls: // void StudentInfo::PrintStudent(ostream& Out) { if (StudentName != "Nothing") { Out << "Name:" << '\n'; Out << '\t' << StudentName << '\n'; } if (StudentPhoneNumber != "(000) 000-0000") { Out << "Phone Number:" << '\n'; Out << '\t' << StudentPhoneNumber << '\n'; } if (StudentEmailAddress != "Nothing") { Out << "Email:" << '\n'; Out << '\t' << StudentEmailAddress << '\n'; } if (StudentStreetLine1 != "Nothing" || StudentStreetLine2 != "Nothing" || StudentCity != "Nothing" || StudentState != "Nothing" || StudentZip != "00000") { Out << "Address: " << '\n'; if (StudentStreetLine1 != "Nothing") { Out << '\t' << StudentStreetLine1 << '\n'; } if (StudentStreetLine2 != "Nothing") { Out << '\t' << StudentStreetLine2 << '\n'; } if (StudentCity != "Nothing") { Out << '\t' << StudentCity; if (StudentState != "Nothing" || StudentZip != "00000") Out << ", "; } if (StudentState != "Nothing") { Out << '\t' << StudentState << " "; } if (StudentZip != "00000") { Out << '\t' << StudentZip << " "; } Out << '\n'; } if (OtherInfo != "Nothing") { Out << "Other:" << '\n'; Out << '\t' << OtherInfo << '\n'; } Out << '\n'; return; } //////////////////////////////////////////////////////////////// printStudentInfo // Print students info if command print students is used. // // Parameters: none. // // Pre: Student_Array was initialized // // Post: None // // Returns: Nothing // // Called by: Main // Calls: GetStudentInfoPresent() // PrintStudent(Out) // void Array_Controller::printStudentInfo(ofstream& Out, StudentInfo &s) { for (int index = 0; index <= 99; index++) { if (Student_Array[index].GetStudentInfoPresent() == true) { Student_Array[index].PrintStudent(Out); } } return; } //////////////////////////////////////////////////////////////// PrintItem // Prints item info if print items command is used. // // Parameters: none // // Pre: Class ItemINof was initialized. // // Post: None // // Returns: Nothing // // Called by: Main // Calls: // void ItemInfo::PrintItem(ostream& Out) { if (ItemName != "Nothing" ) { Out << "Item:" << '\n'; Out << '\t' << ItemName << '\n'; } if (ItemType != "Nothing" ) { Out << "Media Type:" << '\n'; Out << '\t' << ItemType << '\n'; } if (ItemAuthor != "Nothing" ){ Out << "by:" << '\n'; Out << '\t' << ItemAuthor << '\n'; } if (ItemOwner != "Nothing" ){ Out << "Owner:" << '\n'; Out << '\t' << ItemOwner << '\n'; } if (ItemPrice != "$0.00" ){ Out << "Price:" << '\n'; Out << '\t' << ItemPrice << '\n'; } if (ItemAvailability != "Nothing" ) { Out << "Availability:" << '\n'; Out << '\t' << ItemAvailability << '\n'; } Out << '\n'; return; } //////////////////////////////////////////////////////////////// PrintItem2 // The same as print item info1 above. minus the email addres output. // // Parameters: // // Pre: Item class was initialized. // // Post: None // // Returns: Nothing // // Called by: Main // Calls: // void ItemInfo::PrintItem2(ostream& Out) { if (ItemName != "Nothing" ) { Out << "Item:" << '\n'; Out << '\t' << ItemName << '\n'; } if (ItemType != "Nothing" ) { Out << "Media Type:" << '\n'; Out << '\t' << ItemType << '\n'; } if (ItemAuthor != "Nothing" ){ Out << "by:" << '\n'; Out << '\t' << ItemAuthor << '\n'; } if (ItemPrice != "$0.00" ){ Out << "Price:" << '\n'; Out << '\t' << ItemPrice << '\n'; } if (ItemAvailability != "Nothing" ) { Out << "Availability:" << '\n'; Out << '\t' << ItemAvailability << '\n'; } return; } //////////////////////////////////////////////////////////////// printItemInfo // This method prints the Item_array into the output file. // // Parameters: ofstream& Out, ItemInfo &i // // Pre: The class ItemInfo has to have been created along with Array_Controller // // Post: None // // Returns: Nothing // // Called by: Main // Calls: GetItemInfoPresent(); // PrintItem(Out) // void Array_Controller::printItemInfo(ofstream& Out, ItemInfo &i) { for (int index = 0; index <= 99; index++) { if (Item_Array[index].GetItemInfoPresent() == true) { Item_Array[index].PrintItem(Out); } } return; } //////////////////////////////////////////////////////////////// printEmailAddress // Searches through the arrays and prints an email address and its associated items. // // Parameters: bool success // // Pre: The classes were initialized. // // Post: None // // Returns: success // // Called by: Main // Calls: GetStudentEmailAddress() // PrintStudent(Out) // GetItemOwner() // PrintItem2(Out) // bool Array_Controller::printEmailAddress(ofstream& Out, StudentInfo &s, ItemInfo &i, string PrintEmail) { bool success = false; for (int index = 0; index <= 99; index++){ if (Student_Array[index].GetStudentEmailAddress() == PrintEmail){ Student_Array[index].PrintStudent(Out); success = true; } } for (int index = 0; index <= 99; index++){ if (Item_Array[index].GetItemOwner() == PrintEmail){ Item_Array[index].PrintItem2(Out); Out << '\n'; success = true; } } return success; } //////////////////////////////////////////////////////////////// GetStudentInfoPresent // This method Returns StudentInfoPresent to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentInfoPresent // // Called by: Main, print methods, input methods. // Calls: None // bool StudentInfo::GetStudentInfoPresent() { return StudentInfoPresent; } //////////////////////////////////////////////////////////////// GetStudentName // This method Returns StudentName to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentName // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentName() { return StudentName; } //////////////////////////////////////////////////////////////// GetStudentPhoneNumber // This method Returns StudentPhoneNumber to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentPhoneNumber // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentPhoneNumber() { return StudentPhoneNumber; } //////////////////////////////////////////////////////////////// GetStudentEmailAddresse // This method Returns StudentEmailAddress to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentEmailAddress // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentEmailAddress() { return StudentEmailAddress; } //////////////////////////////////////////////////////////////// GetStudentStreetLine1 // This method Returns StudentStreetLine1 to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentStreetLine1 // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentStreetLine1() { return StudentStreetLine1; } //////////////////////////////////////////////////////////////// GetStudentStreetLine2 // This method Returns StudentStreetLine2 to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentStreetLine2 // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentStreetLine2() { return StudentStreetLine2; } //////////////////////////////////////////////////////////////// GetStudentCity // This method Returns StudentCity to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentCity // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentCity() { return StudentCity; } //////////////////////////////////////////////////////////////// GetStudentState // This method Returns StudentState to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentState // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentState() { return StudentState; } //////////////////////////////////////////////////////////////// GetStudentZip // This method Returns StudentZip to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentZip // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetStudentZip() { return StudentZip; } //////////////////////////////////////////////////////////////// GetOtherInfo // This method Returns OtherInfo to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: OtherInfo // // Called by: Main, print methods, input methods. // Calls: None // string StudentInfo::GetOtherInfo() { return OtherInfo; } //////////////////////////////////////////////////////////////// GetItemInfoPresent // This method Returns ItemInfoPresent to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemInfoPresent // // Called by: Main, print methods, input methods. // Calls: None // bool ItemInfo::GetItemInfoPresent() { return ItemInfoPresent; } //////////////////////////////////////////////////////////////// GetItemName // This method Returns ItemName to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemName // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemName() { return ItemName; } //////////////////////////////////////////////////////////////// GetStudentName // This method Returns GetStudentName to whomever called it. // // Parameters: None. // // Pre: The class StudentInfo Exists // // Post: None // // Returns: StudentName; // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemType() { return ItemType; } //////////////////////////////////////////////////////////////// GetItemAuthor // This method Returns ItemAuthor to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemAuthor // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemAuthor() { return ItemAuthor; } //////////////////////////////////////////////////////////////// GetItemOwner // This method Returns ItemOwner to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemOwner // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemOwner() { return ItemOwner; } //////////////////////////////////////////////////////////////// GetItemPrice // This method Returns ItemPrice to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemPrice // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemPrice() { return ItemPrice; } //////////////////////////////////////////////////////////////// GetItemAvailability // This method Returns ItemAvailability to whomever called it. // // Parameters: None. // // Pre: The class ItemInfo Exists // // Post: None // // Returns: ItemAvailability // // Called by: Main, print methods, input methods. // Calls: None // string ItemInfo::GetItemAvailability() { return ItemAvailability; } // ============================================================================ // **************************************************************************** int main (int argc, char* argv[]){ string InputCommand; // Variable which holds an input command string InputCommandLine; // Variable which holds an input command line string PrintCommand; // Variable which holds an print command string PrintEmail; // Variable which holds an print email string DeleteEmailAddress; // Variable which holds an addresss to be deleted bool OutcomeAddS; // Variable which holds an outcome a bool test bool OutcomeAddI; // Variable which holds an outcome a bool test Array_Controller c; // Declaring c as type Array_Controller ItemInfo i; // Declaring i as type ItemInfo StudentInfo s; // Declaring s as type StudentInfo ifstream In("commands.data"); ofstream Out("output.data"); // ============================================================================ // **************************************************************************** if (argc > 1 && atoi(argv[1])==1) { // DEBUG_FLAG = atoi(argv[1]); // *Added by the instructor } // else if (argc > 1 && atoi(argv[1])==2){ string ccommand; cout << "> What would you like to do? " << '\n'; cout << "> print items or print students " << '\n'; cout << "> " << '\n'; cin >> ccommand; if (ccommand == "print items") { c.printStudentInfo(Out, s); cout << "please check the output.data file"; } else if (ccommand == "print items") { c.printItemInfo(Out, i); cout << "please check the output.data file"; } else {cout << "> please use one of the above commands";} } else if (argc > 1 && atoi(argv[1])==3){ cout << "> This project was harder than it needed to be"; cout << "> =( =( =( =("; } // ============================================================================ // **************************************************************************** getline(In, InputCommandLine); while ( In ){ istringstream strin(InputCommandLine); Out << InputCommandLine << endl; strin >> InputCommand; if (InputCommandLine == "add student"){ OutcomeAddS = c.ADDStudent(In); if (OutcomeAddS == true){ Out << "Success" << endl; } else {Out << "Failure" << endl;} } else if (InputCommandLine == "add item"){ OutcomeAddI = c.ADDItem(In); if (OutcomeAddI == true){ Out << "Success" << endl; } else {Out << "Failure" << endl;} } else if (InputCommand == "delete"){ strin >> DeleteEmailAddress; if (c.ArrayEmailDelete(DeleteEmailAddress) == true) { Out << "Success" << endl; } else {Out << "Failure" << endl;} } else if (InputCommand == "print"){ strin >> PrintCommand; if (PrintCommand == "students") { c.printStudentInfo(Out, s); } else if (PrintCommand == "items") { c.printItemInfo(Out, i); } else { PrintEmail = PrintCommand; if (c.printEmailAddress(Out, s, i, PrintEmail) == false) { Out << PrintEmail << " not found." <> temp; cout << "> There was an error reading the inputfile and/or command" << endl; } In.ignore(255, '\n'); getline (In, InputCommandLine); } In.close(); // Close command.data file Out.close(); // Close output.data file return 0; // return 0 if program was successful } // End of Main