#include #include #include #include #include #include "OrganizingTypes.h" using namespace std; /* readItem Parameters: Name - Name of item Type - Type of Media Author - Author of Media Email - Owner's email address Price - Cost of Media Availability - Availability of Media In - Input file stream pre-conditions: None post-conditions: The first six variables passed by reference have obtained a value from the instream where applicable, if not applipicable, the value of the string is set to "". Calls:None */ void readItem(string& Name, string& Type, string& Author, string& Email, string& Price, string& Availability, ifstream& In); /* readStudent Parameters: Name - Name of Student Number - Student's phone number Email - Student's Email Street 1 - first part of street address Street 2 - second part of street address city/state/zip - third part of street address Other-Miscellaneous comment In - Input file stream pre-conditions: None post-conditions: The first nine variables passed by reference have obtained a value from the instream where applicable, if not applipicable, the value of the string is set to "". Calls:None*/ void readStudent(string& Name, string& Number, string& Email, string& Street1, string& Street2, string& city, string& state, string& zip, string& Other, ifstream& In); int main() { ifstream sIn;//student input file stream ifstream cIn;//command input file stream ifstream mIn;//media input file stream ofstream Out;//output file stream sIn.open("students.data"); mIn.open("items.data"); cIn.open("commands.data"); Out.open("output.data"); Organizer Log;//Log of all students participating string Name="";// used to assign values to name of item and student - called by various functions string Number="";// used to assign phone number to student - called by various functions string Email="";// used to assign values to Email of item and student - called by various functions string Street1="";// string Street2="";// string city=""; // Used for values in the street address- called by various functions string state=""; // string zip=""; // string Other=""; // used to assign miscellaneous comments string Type=""; // string Author=""; // Describes Media - see above string Price=""; // string Availability=""; // string Input; // Line of input that is parsed for reading from command file string Command=""; // string variable to easily sort out command file string Command2=""; // string variable to easily sort out command file bool WasValid=true; // used as a return value by various functions in order to determine if an action was successful. readStudent(Name,Number,Email,Street1,Street2,city,state,zip,Other,sIn); //Loads Student information into the arrays. while(sIn) { Log.AddStudent(Name,Number,Email,Street1,Street2,city,state,zip,Other); readStudent(Name,Number,Email,Street1,Street2,city,state,zip,Other,sIn); } readItem(Name,Type,Author,Email,Price,Availability,mIn); //Loads media information into the arrays. while(mIn) { Log.AddItem(Name,Type,Author,Email,Price,Availability); readItem(Name,Type,Author,Email,Price,Availability,mIn); } getline(cIn,Input,'\n'); while (cIn) { if (Input=="") getline(cIn,Input,'\n'); Command=""; Command2=""; string Name=""; Number=""; Email=""; Street1=""; Street2=""; city=""; state=""; zip=""; Other=""; Type=""; Author=""; Price=""; Availability=""; istringstream In(Input); In>>Command; In>>Command2; if (Command=="add") { if (Command2=="item") { readItem(Name,Type,Author,Email,Price,Availability,cIn); WasValid=Log.AddItem(Name,Type,Author,Email,Price,Availability); Out<>Command; Out<