#include #include #include #include #include #include #include using namespace std; //CLASS STUDENT //TO hold info about Student. /*The first class you will create will hold student information. Each "student" should store that student's name, phone number, email address, street name with number, apartment letter and/or number, city, state, zip code, and other. (We will assume each student has standard U.S. addresses). Each student class should provide access functions to private data to update/view the information. Additionally, each student should be able to print to a stream (this will be explained in class) in the following format, where italics represent sample information: Name: Solomon S. Gifford Phone Number: (540) 555-1234 E-mail: sgifford@vt.edu Address: 1776 Liberty Lane Apartment #25 Blacksburg, VA 24060 Other: I am an Instructor...btw, my cell is (540) 555-4321. */ class Student { private: string name; string phone; string email; string address1; string address2; string city; string state; double zipcode; string other; public: Student(); //The following will print the private data members to the stream that is passed to it void printStudent(ostream&); //The following function will add student information directly from input void addInfo(ifstream&); //The following will access the email address of corresponding to the one passed to it string getEmail(){return email;} //The following will "delete" set all private date to "!!" with the exception of the zipcode 123456789 void remove(); }; //=================================================================================================================== /* //CLASS ITEM The second class will be a multimedia item. Each item will have a name, a type, an author, an owner (which will be a student email), a price, a nd a field indicating whether the item is one of the following: will sell, will rent, will trade, will lend, or none of the above. Each student class should provide access functions to private data to update/view the information. Additionally, each item should be able to print to a stream (this will be explained in class) in the following format, where italics represents sample information: Item: I Surrender All Media Type: CD by: Clay Crosse Owner: sgifford@vt.edu Price: $4.50 Availability: Will Rent */ class Item { private: string name; string type; string author; string owner; string avail; string price; public: Item(); //The following function will add student information directly from input void addInfo(ifstream&); //The following will "delete" set all private date to "!!" void remove(); //The following will print the private data members to the stream that is passed to it void printItem(ostream& out); //The following will print the private data members(without OWNER) to the stream that is passed to it void OprintItem(ostream& out); //The following will access the email address of corresponding to the one passed to it string getOwner(){return owner;} }; //=================================================================================================================== /* You will then create a third class that will manage the first two classes by storing an array of students and an array of multimedia items. This class will initially (constructor, we'll learn this in class) open two files. The first will be a list of students with accompanying information named "students.data". The second file will be a list of multimedia items named "items.data". Additionally, this class will provide methods that implement the commands listed below. Note: you must only provide methods to implement the commands, not get the commands from the command file and not to parse the commands. The commands will be read from a file named "commands.data" and will not be read nor parsed by the classes. All output will be written to a file named "output.data". Echo each command to the file and then display each command's output. The functions are as follows: ###print students Print to the file all students in the order they were added to the array. A single endline should be added after each student. ###print items Print all items in the order they were added to the array. A single endline should be added after each item. ###print Where emailaddress is a students email address. This should first print the student's data and then all items s/he has. Do NOT print his/her email address again for each item. A single endline should be added after the student's data has been written. ###add item @Item: I Surrender All @Media Type: CD @by: Clay Crosse @Owner: sgifford@vt.edu @Price: $4.50 @Availability: Will Rent @@ ##add student @Name: Solomon S. Gifford @Phone Number: (540) 555-1234 @E-mail: sgifford@vt.edu @Address Line 1: 1776 Liberty Lane @Address Line 2: Apartment #25 @City: Blacksburg @State: VA @Zipcode: 24060 @Other: I am an Instructor...btw, my cell is (540) 555-4321. @@ ###delete Where emailaddress is a students email address. This will require you to search BOTH the array of students and the array of items, deleting any student or item with that email address. Since your arrays are not dynamic, you won't be able to just delete the array position. You can either set the contents to default values or you can add a field to your classes to indicate that the item has been deleted. Note: notice that this will leave "holes" in the arrays where students or items have been deleted. Don't forget when adding an item or student to an array that since these are "deleted" they can be filled first before adding to the end of the data in the arrays. Print "Success" or "Failure" to the output file depending on the result of the delete. Put it on the line after the command and then another endline. ###quit exits your program don't forget to close your filestreams */ class Controller { public: Controller(); //Defualt Constructor ~Controller(); Controller(char*,char*);//constructor to open input files items.data students.data //also creates output.data and opens commands.data //File I/O Objects //ofstream Out; ifstream IN_Student; ifstream IN_Item; ifstream IN_Command; void Run();//does parsing of input files. void Print_Student(ostream&);//print student list void Print_Item(ostream&);//print item list void Print(ostream&,string); bool Studentsearch(string); //checks to see if email is present in student list int SFoundLocation(string); //returns location in list where the email is present. bool Itemsearch(string); //checks to see if email is present in student list int IFoundLocation(string); //returns location in list where the email is present. void delS(string);//calls remove function for Student object void delI(string);//calls remove function for Item object int get_no_students(){return no_students;}//returns # in list int get_no_items(){return no_items;} private: Student student_list[100];//stores students Item item_list[100];//stores items int no_students;//ctrs for lists int no_items; }; //=================================================================================================================== Student::Student() { name="!!"; phone="!!"; email="!!"; address1="!!"; address2="!!"; city="!!"; state="!!"; zipcode=123456789; other="!!"; } //----------------------------------------------------------------------------------------- void Student::addInfo(ifstream& IN_Student) { string Entry; while((IN_Student)&& (Entry!="@@") ) { getline(IN_Student,Entry,'\n'); if(Entry=="@Name:") { getline(IN_Student,name,'\n'); //cout<< "MY NAME"<< name<> zipcode; } if(Entry=="@Other:") { getline(IN_Student,other); } }//end while }//end addInfo //----------------------------------------------------------------------------------------- void Student::remove() { name=("!!"); phone=("!!"); email=("~~"); address1=("!!"); address2=("!!"); city=("!!"); state=("!!"); zipcode=(123456789); other=("!!"); } //----------------------------------------------------------------------------------------- void Student::printStudent(ostream& out) { if(name!="!!") { out<< "Name:" <>Command; if(Command=="print")//PRINT { IN_Command>>Commandvar; if(Commandvar=="students")//STUDENT LIST { Out<<"print students"<>Commandvar; Out<< "delete " << Commandvar <> Commandvar; if(Commandvar=="item") { Out << "add item" << endl; word=true; //GETTING ITEM TO ADD if(word) { Item newItem; newItem.addInfo(IN_Command); IN_Command.ignore(255,'\n'); //check to see if no email was enter, if there is anymore room in arry, or if the owner is already in the student list if( (newItem.getOwner()=="!!") || ((get_no_items()+1)==101) || (!(Studentsearch(newItem.getOwner()))) ) { //cout<<"Failure"<