// Project 1 for CS 1704 // Programmer: Joshua Drenan //OS: Windows XP Pro //System: Pentium 4 2.8 Ghrz, 1 Gig of Ram //Compiler: Visual C++ .NET 2003 //Last Modified: Febuary 18, 2004 // //Purpose: // The purpose of this program is too read in a list of cities and their neighbors along with // the distance between neighbors and to make a comprehensive graphic information system out of it. // You are able to add/remove cities and routes, then the program writes the results of it's commands to a file. // The program uses an array of structs which contains a list of the neighbors, a count of the neighbors, // strings for both the Name of the city and the state it is in and a int for the distance of routes. // // 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. // // <9043-21158> //#include "P2.h" #include #include #include #include #include using std::cout; using std::cin; using std::endl; using std::string; using std::setw; using std::ios; using std::ifstream; using std::ofstream; using namespace std; //setprecision(2); //enum available {willsell, willrent, willtrade, willlend, noneoftheabove}; class Student{ public: Student(); friend class Organize; string GetName() const {return Name;} string GetPhone() const {return Phone;} string GetMail() const {return Mail;} string GetStreet() const {return Street;} string GetApart() const {return Apart;} string GetCity() const {return City;} string GetState() const {return State;} string GetZip() const {return Zip;} string GetOth() const {return Other;} private: string Name; string Phone; string Mail; string Street; string Apart; string City; string State; string Zip; string Other; }; class Item{ public: Item(); friend class Organize; string GetIName() const {return IName;} string GetMed()const {return Media;} string GetAuthor() const {return Author;} string GetOwn() const {return Owner;} float GetPrice() const {return Price;} string GetAvail() const {return Available;} private: string IName; string Media; string Author; string Owner; float Price; string Available; }; class Organize{ public: Organize(); Student Students[100]; Item Items[100]; void PrintStud (); void PrintItem (); bool PrintMail (string EMail); bool AddItem (string NIName, string MedT, string By, string Own, float Pric, string Avail); bool AddStudent (string NName, string NPH, string EMail, string Stret, string Apar, string Cit, string Stat, string Zipp, string Othe); bool Delete (string EMail); void Quit (); }; int main(){ Organize Med; stringstream ss (stringstream::in | stringstream::out); ifstream ifstr("commands.data", ios::in); ofstream ofst("output.data", ios::app); string NName="æ", New2="æ", New3="æ", New4="æ", New5="æ", New6="æ", New7="æ", New8="æ", Command, info, Zipp, Dummy; float Pric=-1, PT=0.00; int ZipT=0; while (0==0){ ss.str("");ss.flush();ss.clear(); getline(ifstr, Command, '\n'); if (Command == "print students"){ Med.PrintStud(); Command="a";} if (Command == "print items"){ Med.PrintItem(); Command="a";} if (Command == "add item"){ ofst<<"add item\n"; getline( ifstr, info, '\n'); while ((info != "@@")){ if (info == "@Item:"){ getline( ifstr, info, '\n'); NName=info;} if (info == "@Media Type:"){ getline( ifstr, info, '\n'); New2=info;} if (info == "@by:"){ getline( ifstr, info, '\n'); New3=info;} if (info == "@Owner:"){ getline( ifstr, info, '\n'); New4=info;} if (info == "@Price:"){ ifstr.get(); getline( ifstr, info, '\n'); ss<>PT) Pric=PT;} if (info== "@Availability:"){ getline( ifstr, info, '\n'); New5=info;} getline( ifstr, info, '\n');} if (Med.AddItem(NName, New2, New3, New4, Pric, New5)) ofst<<"Success\n"; else ofst<<"Failure\n"; Pric=-1;} if (Command == "add student"){ ofst<<"add student\n"; getline( ifstr, info, '\n'); while ((info != "@@")){ if (info == "@Name:"){ getline( ifstr, info, '\n'); NName=info;} if (info == "@Phone Number:"){ //if ((info[0] == '(') && (info[4]==')') && (info[9]=='-')){ getline( ifstr, info, '\n'); New2=info;}//} if (info == "@E-mail:"){ getline( ifstr, info, '\n'); New3=info;} if (info == "@Address Line 1:"){ getline( ifstr, info, '\n'); New4=info;} if (info == "@Address Line 2:"){ getline( ifstr, info, '\n'); New5=info;} if (info == "@City:"){ getline( ifstr, info, '\n'); New6=info;} if (info == "@State:"){ getline( ifstr, info, '\n'); New7=info;} if (info == "@Zipcode:"){ getline( ifstr, info, '\n'); ss<>ZipT) Zipp=info;} if (info == "@Other:"){ getline( ifstr, info, '\n'); New8=info;} getline( ifstr, info, '\n');} if (Med.AddStudent(NName, New2, New3, New4, New5, New6, New7, Zipp, New8)) ofst<<"Success\n"; else ofst<<"Failure\n";} if (Command == "quit"){ ofst<<"quit\n"; Med.Quit();} ss.str("");ss.flush();ss.clear(); Dummy=""; ss<>Dummy; if (Dummy == "print"){ //ss<>NName; ofst<<"print "<>NName; ofst<<"delete "<>ZipT) Students[a].Zip=info;} getline( ifstr, info, '\n');} ifstr.get(); getline( ifstr, info, '\n'); a++;} ifstr.close(); ifstream itfstr("items.data", ios::in); if (!itfstr){ ofstream ofstr("output.data", ios::app); ofstr<<"Not opening item stream";} a=0; while ((a<100) && (!itfstr.eof())) { getline( itfstr, info, '\n'); while ((info != "@@") && (!itfstr.eof())){ if (info == "@Item:"){ getline( itfstr, info, '\n'); Items[a].IName=info;} if (info == "@Media Type:"){ getline( itfstr, info, '\n'); Items[a].Media=info;} if (info == "@by:"){ getline( itfstr, info, '\n'); Items[a].Author=info;} if (info == "@Owner:"){ getline( itfstr, info, '\n'); Items[a].Owner=info;} if (info == "@Price:"){ itfstr.get(); itfstr>>Items[a].Price; g=itfstr.get();} if (info== "@Availability:"){ getline( itfstr, info, '\n'); Items[a].Available=info;} getline( itfstr, info, '\n');} getline( itfstr, info, '\n'); a++;} itfstr.close();} void Organize::PrintStud(){ ofstream ofstr("output.data", ios::app); ofstr<<"print students \n"; for (int a=0; a<100; a++){ if (Students[a].GetMail()!="æ"){ if (Students[a].GetName()!="æ"){ ofstr<<"Name: \n"; ofstr<