//Item.cpp #include "Item.h" #include #include using namespace std; Item::Item(){ Name = "blank"; Author = "blank"; Type = "blank"; Owner = "blank"; Availability = "blank"; Price = -1.00; deleted = false; } /* If you reach the @@ line without finding an email address (in other words, the "@Owner:" line followed by a line with text...you don't have to check to make sure the email is in the correct format) simply discard the addition*/ //////////////////////////////////////////////////////////////// // // // Parameters: // // // Pre: // // Post: // // Returns: Describe what value the function returns, if any. // // Called by: // Calls: // bool Item::AddItem(ifstream& inFile, string ReadMe, Student Arr[], int Num){ Name = "blank"; Author = "blank"; Type = "blank"; Owner = "blank"; Availability = "blank"; Price = -1.00; bool Owned = false; //cout << " adding " << endl; //string ReadMe; //getline(inFile, ReadMe, '\n'); //while ReadMe is not equal to "@@" while(ReadMe != "@@"){ //cout << endl << "read me " << ReadMe; if(ReadMe == "@Item:"){ getline(inFile, Name, '\n'); } else if(ReadMe == "@Media Type:"){ getline(inFile, Type, '\n'); } else if(ReadMe == "@by:"){ getline(inFile, Author, '\n'); } else if(ReadMe == "@Owner:"){ //cout << "\n calling "; getline(inFile, Owner, '\n'); Owned = EmailExists(Arr, Owner, Num); } else if(ReadMe == "@Price:"){ inFile.ignore(1, '$'); inFile >> Price; //cout << "\n price " << Price < // // // Parameters: // // // Pre: // // Post: // // Returns: Describe what value the function returns, if any. // // Called by: // Calls: // void Item::PrintInfo(ofstream& outFile){ if(Name != "blank"){ outFile << "Item:\n"; outFile << " " << Name < 0.0){ outFile << "Price:\n"; outFile << " " << "$" << fixed << setprecision(2) << Price << endl; } if(Availability != "blank"){ outFile << "Availability:\n"; outFile << " " << Availability << endl; } outFile << endl; } string Item::ReturnName(){ return Name; } string Item::ReturnAuthor(){ return Author; } string Item::ReturnType(){ return Type; } string Item::ReturnOwner(){ return Owner; } string Item::ReturnAvailability(){ return Availability; } float Item::ReturnPrice(){ return Price; } bool Item::EmailExists(Student Arr[], string s,int Num){ ///cout << "s " << s << "9 " << endl; bool exists = false; for(int i = 0; i