// Katherine Gribovsky // np214089 ArrayOfPointers.h #define ArrayOfPointers_h /* This module written by project director. The interface will not be altered during project 1, but the director may choose to reimplement things at any time. The module will follow the rules set forth by the abstract comments. */ template class ArrayOfPointers { TD** data; int size; int used; public: ArrayOfPointers(int insize=50) { //array of insize pointers to type TD will be created size=insize; data=new TD* [size]; used=0; } ArrayOfPointers(const ArrayOfPointers& orig) { size=orig.size; data=new TD* [size]; used=orig.used; for (int i=0; i #include Company::Company(String s, String s1, URL url, Provider *p) { name=s; webmaster=s1; homepage=url; prov=p; } Company::Company(const Company &c) { name=c.name; webmaster=c.webmaster; homepage=c.homepage; prov=c.prov; } Company::~Company() { free(); } Company &Company::operator =(const Company &c) { name=c.name; webmaster=c.webmaster; homepage=c.homepage; prov=c.prov; return *this; } bool Company::operator <(const Company &c) const { if (name (const Company &c) const { if (name> c.name) return true; else return false; } bool Company::operator !=(const Company &c) const { if (name!= c.name) return true; else return false; } bool Company::operator ==(const Company &c) const { if (name== c.name) return true; else return false; } URL Company::getHomePage()const { return homepage; } String Company::getKey()const { return name; } String Company::getName()const { return name; } Provider* Company::getProvider()const { return prov; } String Company::getThread()const { return webmaster; } String Company::getWebmaster()const { return webmaster; } void Company::copy(const Company&c) { name=c.name; homepage=c.homepage; prov=c.prov; webmaster=c.webmaster; } void Company::free() { } void Company:: readin(istream&in) { String provider; //*prov= new Provider; in>>ws>>name>>ws>>webmaster>>ws>>homepage>>ws>>provider; // cout<<" I'm in readin provider "<locate(provider); // cout<getName()<getName()<<" Fee:$ "<getFee()< #include "String.h" #include "URL.h" #include "Provider.h" #include "SingletonProvidersList.h" class Company{ String name; //Primary Key String webmaster; //Thread Key URL homepage; Provider* prov; public: Company(String = "none", String = "none", URL = URL(), Provider* = NULL); Company(const Company&); ~Company(); Company& operator = (const Company&); bool operator == (const Company&) const; //two Company objects are equal if and only if their names are equal bool operator != (const Company&) const; //two Company objects are not equal if and only if their names are not equal bool operator < (const Company&) const; //a Company objects if less than another Company object if and only if the // name is less than the other name bool operator > (const Company&) const; //a Company objects if greater than another Company object if and only if the // name is greater than the other name String getName() const; String getWebmaster() const; URL getHomePage() const; Provider* getProvider() const; String getKey() const; String getThread() const; friend istream& operator >> (istream& is, Company& obj){ obj.readin(is); return is; } friend ostream& operator << (ostream& os, const Company& obj){ obj.writeout(os); return os; } private: void copy(const Company&); void free(); void readin(istream&); void writeout(ostream&) const; }; #endif # include "OrderedThreadedList.cpp" template class OrderedThreadedList; template class OrderedThreadedList; # include "OrderedThreadedList.h" template OrderedThreadedList::OrderedThreadedList() { //constructor curr=NULL; root=NULL; tfirst=NULL; } template OrderedThreadedList::OrderedThreadedList(const OrderedThreadedList&o) { // copy constructor root = NULL; curr = NULL; tfirst= NULL; copyHelper(o.root); } template void OrderedThreadedList::copyHelper(OrderedThreadedListnode *o) { // helps to copy function if (o==NULL) return; else{ add(*(o->data)); copyHelper(o->left); copyHelper(o->right); } } template OrderedThreadedList::~OrderedThreadedList() { // destructor free(); } template void OrderedThreadedList::goFirst() { if(! isEmpty()) while( curr->prev!=NULL) curr=curr->prev; } template void OrderedThreadedList::goLast() { if (!isEmpty()) while(curr->next!=NULL) curr=curr->next; } template void OrderedThreadedList::goNext() { if (curr !=NULL) curr=curr->next; } template void OrderedThreadedList::goPrev() { if (curr !=NULL) curr=curr->prev; } template void OrderedThreadedList::goFirstThread() { if (!isEmpty()) curr=tfirst; } template void OrderedThreadedList::goNextThread() { if (curr!=NULL) curr=curr->tnext; } template int OrderedThreadedList::isEmpty() const { if (root==NULL) return 1; else return 0; } template int OrderedThreadedList::isOffList() const{ if(curr == NULL) return 1; return 0; } template OrderedThreadedList& OrderedThreadedList:: operator = (const OrderedThreadedList&o) { // operator = free(); copy(o); return *(this); } template int OrderedThreadedList::locate(OTLDataKey o) { curr = root; while( curr != NULL) { if((*(curr->data)).getKey() == o) return 1; if(o < (*(curr->data)).getKey()) curr = curr->left; else curr = curr->right; } return 0; } template OTLData OrderedThreadedList::getFromCurrent() const { OTLData *p= new OTLData; if ( curr !=NULL) return *(curr->data); else return *(p); } template void OrderedThreadedList::putToCurrent(OTLData o) { *(curr->data)=o; } template bool OrderedThreadedList::add (OTLData o) {//1 bool flag=true; OrderedThreadedListnode *newnode, // newnode *helper, *tcurr, *thread_puppy, *first; //helper pointers // prepearing new node newnode= new OrderedThreadedListnode; newnode->data=new OTLData; newnode->left=NULL; newnode->right=NULL; newnode->prev=NULL; newnode->next=NULL; newnode->tnext=NULL; if (root==NULL){ // adding root root=newnode; *(root->data)=o; curr=root; tfirst=root; return true; } else {// adding nor root curr=root; while(flag) { // looking where to put the node if (*(curr->data) >o) if (curr->left!=NULL) curr=curr->left; else { // adding node flag=false; curr->left=newnode; *(newnode->data)=o; curr=newnode; } else if (*(curr->data)right!=NULL) curr=curr->right; else { // adding node flag=false; curr->right=newnode; *(newnode->data)=o; curr=newnode; } } } // adjusting thread node tcurr = tfirst; while((tcurr != NULL) && (tcurr->data->getThread() < o.getThread())) { thread_puppy = tcurr; tcurr = tcurr->tnext; } //place at beginning of thread list if( tcurr==tfirst){ newnode->tnext = tfirst; tfirst = newnode; } //place at middle or end of thread list else { newnode->tnext=thread_puppy->tnext; thread_puppy->tnext = newnode; } // adjust successor and pred nodes first=root; while ((first!=NULL)&&(first->left !=NULL)){ helper=first; first=first->left; } tcurr = first; while((tcurr != NULL) && (tcurr->data->getKey() < o.getKey())) { thread_puppy = tcurr; tcurr = tcurr->next; } //place at beginning of thread list if( tcurr==first){ first->prev=newnode; newnode->prev=NULL; if ( first==newnode) first->next=helper; else{ newnode->next = first; first = newnode; } } //place at middle or end of thread list else { newnode->next=thread_puppy->next; newnode->prev=thread_puppy; if (thread_puppy->next !=NULL) thread_puppy->next->prev=newnode; thread_puppy->next = newnode; } } template bool OrderedThreadedList::del (OTLDataKey o) {//1 // This function deletes a person and adjust the Web accordingly // by primary and secondary keys OrderedThreadedListnode *helper=curr, *tprev ; if (locate(o)) {//2 //adjust thread helper=tprev=tfirst; while (helper !=curr) { tprev=helper; helper=helper->tnext; } if (helper==tfirst){ tfirst=curr->tnext; curr->tnext=NULL; } tprev->tnext=curr->tnext; curr->tnext=NULL; // adjusting successor pred nodes if(curr->prev!=NULL) curr->prev->next=curr->next; if (curr->next!=NULL) curr->next->prev=curr->prev; curr->next=NULL; curr->prev=NULL; // deleting the node // node has no childern if ((curr->right==NULL)&&(curr->left==NULL)) { // check if this is root if (root==curr){ root=NULL; delete root; } else{ helper=curr; GoParent(); if (curr->left==helper) curr->left=NULL; else curr->right=NULL; } return true; } // node has a right child else if ((curr->right!=NULL) && (curr->left==NULL)) { helper=curr; if (curr==root){ root=curr->right; curr->right=NULL; return true; } GoParent(); if (curr->left==helper) { curr->left=helper->right; helper->right=NULL; } else if (curr->right==helper) { curr->right=helper->right; helper->right=NULL; } } else // node has one left child if ((curr->left!=NULL) && (curr->right==NULL)) { helper=curr; if (curr==root){ root=curr->left; curr->left=NULL; return true; } GoParent(); if (curr->left==helper) { curr->left=helper->left; helper->left=NULL; } else if (curr->right==helper) { curr->right=helper->left; helper->left=NULL; } } else // node has two children if ((curr->right!=NULL) && (curr->left!=NULL)){ if (curr==root) root=root->left; else { helper=curr; GoParent(); if (curr->left==helper){ curr->left=helper->left; } else{ curr->right=helper->left; } curr=helper; } helper=curr; curr=curr->left; while(curr->right!=NULL) curr=curr->right; curr->right=helper->right; helper->left=NULL; helper->right=NULL; } }// locate }// end of delete function template void OrderedThreadedList::printPrimaryForward(ostream& out) { // printing forward if (root != NULL) inorderPrint(out, root); } template void OrderedThreadedList::inorderPrint(ostream& out, OrderedThreadedListnode *current) { if(current != NULL) { inorderPrint(out, current->left); out<<*(current->data)<< endl; inorderPrint(out, current->right); } } template void OrderedThreadedList::printPrimaryReverse(ostream& out) { // print reverse backPrint(out, root); } template void OrderedThreadedList::backPrint(ostream& out, OrderedThreadedListnode *current) { if(current != NULL) { backPrint(out, current->right); out << *(current->data) << endl; backPrint(out, current->left); } } template void OrderedThreadedList::printThreadForward(ostream& out) { // print thred ordered curr=tfirst; while (curr !=NULL){ out<<*(curr->data)<tnext; } } template void OrderedThreadedList::free() { if (root!=NULL) inorderPrint1(root); } template void OrderedThreadedList::inorderPrint1( OrderedThreadedListnode *current) { if(current != NULL) { inorderPrint1(current->left); current->left=NULL; current->right=NULL; inorderPrint1(current->right); } } template void OrderedThreadedList::copy(const OrderedThreadedList&l) { copyHelper(l.root); } template void OrderedThreadedList::GoParent() { OrderedThreadedListnode *puppylove=NULL, *current; bool flag=true; current = root; if (curr==root) return; else { while(flag) { puppylove = current; if ((*curr->data).getKey() >(*current->data).getKey()) { if (! (curr==current->right)) current = current->right; else flag=false; } else if (! (curr==current->left)) current = current->left; else flag=false; } curr = current; } } 573 #define OrderedThreadedList_h #include "Person.h" #include "String.h" #include "URL.h" #include "Company.h" //OrderedThreadedList in the abstract comments denotes the "current object." //This #define is here to get us ready to templatize later #define OTLData Person #define OTLDataKey String #define OTLThreadKey URL template struct OrderedThreadedListnode { OTLData *data; OrderedThreadedListnode *next; OrderedThreadedListnode *prev; OrderedThreadedListnode *tnext; OrderedThreadedListnode *left; OrderedThreadedListnode *right; }; template class OrderedThreadedList { OrderedThreadedListnode *tfirst; OrderedThreadedListnode *root; OrderedThreadedListnode *curr; public: //automatic: OrderedThreadedList(); // create empty OrderedThreadedList OrderedThreadedList(const OrderedThreadedList&); // copy argument OrderedThreadedList into OrderedThreadedList ~OrderedThreadedList(); // deallocate OrderedThreadedList //iterators: void goFirst(); // abs: isempty() -> there is no current item // | go to first item of OrderedThreadedList void goLast(); // abs: isempty() -> there is no current item // | go to last item of OrderedThreadedList void goNext(); // abs: isempty() -> there is no current item // | go to next item of OrderedThreadedList void goPrev(); // abs: isempty() -> there is no current item // | go to previous item of OrderedThreadedList void goFirstThread(); // abs: isempty() -> there is no current item // | go to the first item according to thread ordering void goNextThread(); // abs: isempty() -> there is no current item // | go to the next item according to thread ordering int isEmpty() const; // abs: return (OrderedThreadedList is empty) int isOffList() const; //abs: return (no current item) //other: OrderedThreadedList& operator = (const OrderedThreadedList&); // abs: data in OrderedThreadedList = data in argument OrderedThreadedList int locate(OTLDataKey); // abs: argument OTLDataKey in OrderedThreadedList -> item containing that OTLDataKey // becomes the current item, locate = 1 // | if OTLDataKey is larger than any in the OrderedThreadedList -> // there is no current item, locate = 0 // | current item is first item with OTLDataKey > argument OTLDataKey, // locate = 0 OTLData getFromCurrent() const; // abs: getFromCurrent = data of current item void putToCurrent(OTLData); // abs: data of current item = data of the argument bool add (OTLData); //abs: OTLData's primary key not in the list yet --> OTLData object inserted // in primary ordering as well as thread ordering, the new item becomes // current item, and return true | overwrite existing data with same primary // key with new data, fix threads if needed and return false bool del (OTLDataKey); // abs: argument OTLDataKey is in the OrderedThreadedList --> // remove that data item from OrderedThreadedList, curr indicates no // current item, del = true // | return false //output: void printPrimaryForward(ostream&); void printPrimaryReverse(ostream&); void printThreadForward(ostream&); private: void free(); //abs: return OrderedThreadedList space to system heap, leaving OrderedThreadedList empty void copy(const OrderedThreadedList&); //abs: OrderedThreadedList = OrderedThreadedList which was passed in void copyHelper(OrderedThreadedListnode*o); // helps to copy the tree void inorderPrint(ostream& out, OrderedThreadedListnode *current); // helper functon to print the tree in order void inorderPrint1(OrderedThreadedListnode *current); // helper function to delete a tree void backPrint(ostream& out, OrderedThreadedListnode *current); // helper function to print the tree backwards void GoParent(); // Goes to the parent node of current }; #endif 4 # include # include "Person.h" Person::Person(String str, URL url, Provider* p) { name=str; homepage=url; prov=p; } Person::Person(const Person& p) { name=p.name; homepage=p.homepage; prov=p.prov; } Person::~Person() { free(); } bool Person::operator> (const Person &p) const { if (name>p.name) return 1; else return 0; } bool Person::operator== (const Person &p) const { if (name==p.name) return 1; else return 0; } bool Person::operator !=(const Person &p) const { if (name!=p.name) return 1; else return 0; } bool Person::operator <(const Person &p) const { if (name< p.name) return 1; else return 0; } Person& Person::operator =(const Person &p) { name=p.name; homepage=p.homepage; prov=p.prov; return *this; } String Person::getName() const { return name; } URL Person::getHomePage() const { return homepage; } Provider* Person::getProvider() const { return prov; } String Person::getKey() const { return name;} URL Person::getThread() const { return homepage;} void Person::copy(const Person&p1) { name=p1.name; homepage=p1.homepage; prov=p1.prov; } void Person::free() { } void Person:: readin(istream&in) { String provider; in>>ws>>name>>ws>>ws>>homepage>>ws>>provider; prov=SingletonProvidersList::Instance()->locate(provider); } void Person::writeout(ostream&out) const { out<<"Name: "<getName())<getFee())< (const Person&) const; //a PERSON objects if greater than another PERSON object if and only if the // name is greater than the other name String getName() const; URL getHomePage() const; Provider* getProvider() const; String getKey() const; URL getThread() const; friend istream& operator >> (istream& is, Person& obj){ obj.readin(is); return is; } friend ostream& operator << (ostream& os, const Person& obj){ obj.writeout(os); return os; } private: void copy(const Person&); void free(); void readin(istream&); void writeout(ostream&) const; }; #endif #include // String ProviderKey ProviderKey; Provider::Provider(String str, double fee1) { name=str; fee=fee1; } Provider::Provider(const Provider& P1) { name=P1.name; fee=P1.fee; } Provider::~Provider() { } bool Provider::operator == (const Provider&P1) const { if (P1.name==name) return 1; else return 0; } bool Provider::operator ==(const ProviderKey &Key1) const { if (Key1==name) return 1; else return 0; } bool Provider::operator !=(const Provider &P1) const { if (P1.name==name) return 0; else return 1; } bool Provider::operator !=(const ProviderKey &Key) const { if (Key==name) return 0; else return 1; } bool Provider::operator<(const ProviderKey &Key) const { if (Key>name) return 0; else return 1; } bool Provider::operator>(const ProviderKey &Key) const { if (Key (const Provider &P1) const { if (name>P1.name) return 0; else return 1; } void Provider::readin (istream &is) { is>>ws>>name>>ws>>fee; } void Provider::writeout(ostream &os) const { os<<"Provider: "< (const ProviderKey&Key, const Provider&P) { if (Key > P.getName()) return 1; else return 0; } #define Provider_h #include "String.h" typedef String ProviderKey; class Provider { String name; double fee; public: Provider(String="none", double=500.0); Provider(const Provider&); ~Provider(); String getKey() const {return name;} String getName() const {return name;} double getFee() const {return fee;} void setFee(double newfee) {fee=newfee;} bool operator != (const Provider&) const; bool operator != (const ProviderKey&) const; bool operator == (const Provider&) const; bool operator == (const ProviderKey&) const; bool operator < (const Provider&) const; bool operator < (const ProviderKey&) const; bool operator > (const Provider&) const; bool operator > (const ProviderKey&) const; friend istream& operator >> (istream& is, Provider& obj){ obj.readin(is); return is; } friend ostream& operator << (ostream& os, const Provider& obj){ obj.writeout(os); return os; } private: void readin(istream& is); void writeout(ostream& os) const; }; bool operator != (const ProviderKey&, const Provider&); bool operator == (const ProviderKey&, const Provider&); bool operator < (const ProviderKey&, const Provider&); bool operator > (const ProviderKey&, const Provider&); #endif //ArrayOfPointers listOfProviders; //This is the actual structure which will be used SingletonProvidersList* SingletonProvidersList::_instance=0; SingletonProvidersList::~SingletonProvidersList(){ delete _instance; } SingletonProvidersList* SingletonProvidersList::Instance(){ if (_instance == 0) _instance = new SingletonProvidersList; return _instance; } SingletonProvidersList::SingletonProvidersList(){ ifstream providersFile("providers.txt"); Provider tempProvider; while (providersFile.peek()!='/'){ providersFile >> tempProvider >> ws; add(tempProvider); } } void SingletonProvidersList::add(const Provider& obj){ Provider* p; p = locate(obj.getName()); if (!p) listOfProviders.insert(obj); else *p = obj; } Provider* SingletonProvidersList::locate(const ProviderKey& key){ return listOfProviders.find(key); } #define SingletonProvidersList_h #include #include "ArrayOfPointers.h" #include "Provider.h" //This class represents the Singleton pattern applied to // create a single lookup table of providers. This is // a type of structure where we want the entire project // to refer to a common strucutre. class SingletonProvidersList{ private: ArrayOfPointers listOfProviders; //This is the actual structure which will be used public: ~SingletonProvidersList(); Provider* locate(const ProviderKey&); void add(const Provider&); public: static SingletonProvidersList* Instance(); //We will use this method to make sure the structure exists // before we access it, and allow us to access the structure private: SingletonProvidersList(); //By making the constructor protected, the compiler // will complain if someone tries to actually create // one of these objects private: static SingletonProvidersList* _instance; //This will be a pointer to the single instance of the // SingletonProvidersList object }; #endif //#define STRING1_H #include #include "String.h" String::String(const char* init) { for(size=0; init[size] != '\0'; size++); data = new char[size+1]; for(int i=0; i<=size; i++) data[i] = init[i]; } String::String(const String&s) { if(this != &s) { size = s.size; data = new char[size+1]; for(int i=0; i<=size; i++) data[i] = s.data[i]; } } String::~String() { free(); } String& String::operator = (const String&s) { if (&s == this) return *this; else { size=s.size; delete [] data; data = new char[size+1]; for(int i=0; i<=size; i++) data[i] = s.data[i]; return *this; } } String& String::operator = (const char* init) { for(size=0; init[size] != '\0'; size++); delete [] data; data = new char[size+1]; for(int i=0; i<=size; i++) data[i] = init[i]; return *this; } bool String:: operator < (const String&s) const { if (*this >s) { return 0; } else if (s == *this) return 0; else return 1; } bool String::operator > (const String&s) const { int i=0, sIze; if (s== *this) return 0; if ((s.sizesize) sIze=size; while (i<=sIze) { if (data[i] < s.data[i]){ return 0;} else if (data[i]>s.data[i]){ return 1; } else i++; } if (( sIze>=i) && (sIze=s.size)) return 1; else return 0; } bool String::operator == (const String&s) const { int i=0, sIze, samelength=0; if (s.size !=size ) return 0; //int i=0, sIze, samelength=0; else { samelength=1; sIze = size; } while(i <=sIze) { if(s.data[i] != data[i]) return 0; i++; } return samelength; } istream& operator >> (istream&in, String&s) { char temp[36]; while(in.peek() == '\n' || in.peek() == ' ') in.get(); in.get(temp, 36, '%'); while(in.peek() != '%') in.get(); in.get(); s = temp; return in; } ostream& operator << (ostream&out, const String &s) { return out << s.data; } void String::free() { delete[] data; } void String::copy(const String&string) { for(int i=1; 1 class String { static int max; //Note: This should be set to 35 in your String.cpp int size; char* data; public: String(const char* init=""); //abs: copy argument character String (terminated by '\0') into String(const String&); //abs: copy argument String into STRING ~String(); //abs: delete STRING String& operator = (const String&); //abs: STRING = argument String String& operator = (const char*); //abs: STRING = argument character String bool operator < (const String&) const; //abs: return (STRI bool operator > (const String&) const; //abs: return (STRING > argument String) bool operator == (const String&) const; //abs: return (STRING == argument String) bool operator != (const String&) const; //abs: return (STRING != argument String) friend istream& operator >> (istream&, String&); //abs: argument istream object == characterString & otherinput // --> argument istream object = otherinput, // argument String = characterString //abs: return (STRING > argument String) //abs: return (STRING != argument String) //abs: argument istream object == characterString & otherinput // --> argument istream object = otherinput, // argument String = characterString friend ostream& operator << (ostream&, const String&); //abs: argument ostream object = original output --> // --> argument ostream object = original output // & argument String private: void free(); //abs: deallocate STRING void copy(const String&); //abs: copy the parameter String into the current object void copy(const char* init); //abs: copy the parameter char String into the current object }; #endif 43 # include # include "URL.h" # include "String.h" bool URL::operator < (const URL&url) const { // true if word< url.word int flag; flag=strcmp(word,url.word); if (flag<0) return 1; else if (flag>0) return 0; if (flag==0) { flag=strcmp(tld, url.tld); if (flag<0) return 1; else if (flag> 0) return 0; if (flag==0) { flag=strcmp(home,url.home); if (flag<0) return 1; else return 0; } } else return 0; } bool URL::operator > (const URL&url) const { if ((*this) < url) return 0; else return 1; } bool URL::operator == (const URL&url) const { if ((strcmp(word,url.word)==0)&&(strcmp(tld,url.tld)==0)&&(strcmp(home,url.home)==0)) return 1; else return 0; } istream& operator >> (istream&in, URL&url) { for(int i=1;i<12;i++) in.ignore(); // String word, tld, home; //while(in.peek() != '.') //pay attention /////in>>url.word; //in.ignore(); //while(in.peek() != '.') //in>>url.tld; //in.ignore(); //while(in.peek() != '/') //in>>url.home; // return in; //problem what about '.' if (in.peek()== '.') in.ignore(); char temp[256]; char temp1[4]; //in.get(url.word, 256, '.'); in.get(temp, 256,'.'); while(in.peek() != '.') in.get(); in.get(); strcpy(url.word,temp); //cout< #include //System defined string functions - can only // be used in this module!!!!! //NOTE: There are several ways to implement this class - you may // find that some members are not used by your implementation. #define MAXLEN 255 #define TLDLEN 3 class URL{ int wordsize; char word[MAXLEN+1]; int homesize; char home[MAXLEN+1]; char tld[TLDLEN+1]; public: //a comparison operator will first compare the "word", // if the two are the same, then it will go on to // compare the "tld", if the two of those are also // the same, it will then compare the "home" bool operator < (const URL&) const; bool operator > (const URL&) const; bool operator ==(const URL&) const; friend istream& operator >> (istream&, URL&); friend ostream& operator << (ostream&, const URL&); }; #endif # include "Web.h" #include #include #include #include # include "Company.h" #include //cout.setf(ios::showpoint); Web::Web(char* nolog) { logfile.open("myWeb.log"); } Web::~Web() { logfile.close(); } void Web::A_add() { int flag;// shows wether a person is in the list or not char choice; // company c or person p cin>>choice; if (choice=='p') {// Adding a Person Person p; cin>>ws>>p>>ws; flag=(listOfPeople.locate(p.getKey())); if (flag)// Updating Person cout<>ws>>c>>ws; flag=(listOfCompanies.locate(c.getKey())); if (flag) cout<>ws>>p>>ws; flag1=listOfPeople.locate(p); flag2=listOfCompanies.locate(p); if (flag1){ //if listOfPeople.del(p); //{ cout<>p; //Person p; //Company c; flag=listOfPeople.locate(p); flag1=listOfCompanies.locate(p); if ((flag)||(flag1)) { cout<<"Found"<>ws>>provider>>ws; cout<<"Person entries using "<getName()==provider) { if (! flag){ // first person cout<>choice1; if (choice1=='N') {//1 cin>>choice2; if (choice2=='F')// Print Forward { if (( listOfPeople.isEmpty())&&(listOfCompanies.isEmpty())) cout<<" Forward Print: Empty Lists\n"; else{ cout<<"Forward Print:\n"; cout<<"-----\n"; listOfPeople.printPrimaryForward(cout); listOfCompanies.printPrimaryForward(cout); cout<<"-----\n"; } } else if (choice2=='B')// print reverse { if (( listOfPeople.isEmpty())&&(listOfCompanies.isEmpty())) cout<<" Backward Print :Empty Lists\n"; else{ cout<<"Backward Print:\n"; cout<<"-----\n"; listOfPeople.printPrimaryReverse(cout); listOfCompanies.printPrimaryReverse(cout); cout<<"-----\n"; } } } else if (choice1=='H') // print by thread value { if (( listOfPeople.isEmpty())&&(listOfCompanies.isEmpty())) cout<<" Threaded Print: Empty Lists\n"; else{ cout<<"Threaded Print:\n"; cout<<"-----\n"; listOfPeople.printThreadForward(cout); listOfCompanies.printThreadForward(cout); cout<<"-----\n"; } } else if ( choice1=='F'){ cin>>fee; cout<<" Printing all person entries with fee over $"<getFee()) >fee){ if (! flag){ // first person cout<>provider; cout<<" Printing all company entries with a provider alphabetically after "<getName() >provider)){ if (! flag){ // first person cout<>given_name; cin>>fee; // listOfPeople.goFirst(); // while (! listOfPeople.isOffList()){ prov=SingletonProvidersList::Instance()->locate(given_name); // cerr<<"I'm in Web U2\n"; if (prov !=NULL){ prov->setFee(fee); // cerr<<"I'm in Web U3\n"; SingletonProvidersList::Instance()->add((*prov)); //cerr<<"I'm in Web U4\n"; cout<<" Fee changed for "< listOfPeople; OrderedThreadedList listOfCompanies; ofstream logfile; public: Web(char* = "nolog"); ~Web(); void A_add(); void D_delete(); void F_find(); void L_listProv(); void P_printSubMenu(); void U_updateFee(); }; #endif 10/17 Started doing the project. Printed out the description, looked it over. I don't understand what do they mean by successor and preddessesor pointers. Why do we need them? 10/18 Didn't work on the project 10/19 The TA explained me how the tree supposed to look and what the successor and predesessor pointers should do. 10/20 Started working on copy constructor. I can't figure out why doesn't this recursive function work. i constantly loose the right part of the tree.Later on, i managed to right it. 10/21 wrote Go Next, Go last, operator=, go parent and all the functions before add. 10/22 Started writing add function. It doesn't seem to compile. I get many compiler errors. I'm stressed. 10/23 The compiler errors i was getting were because i made a mistake in template (i misspelled it.) I finished writing the add function. Thread didn't change, i just used the old one, but previous and next succ and pred had to change, because there was a previous node too. 10/24 Wrote the print functions and delete function. Started writing the delete function. 10/25 My delete function doesn't work for a node which has 2 children or a right child. It crashes. 10/26 I figured out what was the problem- I tried to access memory which wasn't there. Fixed the problem with delete Tested the project on additional outputs, wrote comments. 10/27 Did some additional testing.Submitted the project #include #include #include #include "SingletonProvidersList.h" #include "String.h" #include "ArrayOfPointers.h" #include "URL.h" #include "Person.h" #include "Web.h" #include "Company.h" char get_user_command(){ char command; cin >> command; return command; } int main() { Web myWeb("myWeb.log"); char choice; do{ choice = toupper(get_user_command()); switch(choice){ case 'A': myWeb.A_add(); break; case 'D': myWeb.D_delete(); break; case 'F': myWeb.F_find(); break; case 'L': myWeb.L_listProv(); break; case 'P': myWeb.P_printSubMenu(); break; case 'U': myWeb.U_updateFee(); break; case 'Q': cout << "Quit Selected - destructing list" << endl; break; default: cout << choice << " is an invalid menu option" << endl; break; } } while (choice != 'Q'); return EXIT_SUCCESS; } CFLAGS = -g -Wall OBJs = main.o Company.o OTLtypes.cpp Provider.o Person.o String.o SingletonProvidersList.o OrderedThreadedList.o URL.o Web.o .SUFFIXES: .cpp .cpp.o: ${CC} ${CFLAGS} -c $< runfile: ${OBJs} ${CC} ${CFLAGS} ${OBJs} -o proj3 clean: rm -f *.o depend: makedepend -I. -I/usr/local/gnu/include/g++-3 *.cpp # DO NOT DELETE THIS LINE -- make depend depends on it. OrderedThrededList.o: /usr/local/gnu/include/g++-3/iostream.h OrderedThrededList.o: /usr/local/gnu/include/g++-3/streambuf.h OrderedThrededList.o: /usr/local/gnu/include/g++-3/libio.h OrderedThrededList.o: OrderedThreadedList.h Person.h String.h URL.h OrderedThrededList.o: /usr/include/string.h /usr/include/sys/feature_tests.h OrderedThrededList.o: /usr/include/sys/isa_defs.h Provider.h OrderedThrededList.o: SingletonProvidersList.h OrderedThrededList.o: /usr/local/gnu/include/g++-3/fstream.h OrderedThrededList.o: ArrayOfPointers.h Person.o: /usr/local/gnu/include/g++-3/iostream.h Person.o: /usr/local/gnu/include/g++-3/streambuf.h Person.o: /usr/local/gnu/include/g++-3/libio.h Person.h String.h URL.h Person.o: /usr/include/string.h /usr/include/sys/feature_tests.h Person.o: /usr/include/sys/isa_defs.h Provider.h SingletonProvidersList.h Person.o: /usr/local/gnu/include/g++-3/fstream.h ArrayOfPointers.h Provider.o: Provider.h String.h /usr/local/gnu/include/g++-3/iostream.h Provider.o: /usr/local/gnu/include/g++-3/streambuf.h Provider.o: /usr/local/gnu/include/g++-3/libio.h SingletonProvidersList.o: SingletonProvidersList.h SingletonProvidersList.o: /usr/local/gnu/include/g++-3/fstream.h SingletonProvidersList.o: /usr/local/gnu/include/g++-3/iostream.h SingletonProvidersList.o: /usr/local/gnu/include/g++-3/streambuf.h SingletonProvidersList.o: /usr/local/gnu/include/g++-3/libio.h SingletonProvidersList.o: ArrayOfPointers.h Provider.h String.h String.o: /usr/local/gnu/include/g++-3/iostream.h String.o: /usr/local/gnu/include/g++-3/streambuf.h String.o: /usr/local/gnu/include/g++-3/libio.h String.h URL.o: /usr/local/gnu/include/g++-3/iostream.h URL.o: /usr/local/gnu/include/g++-3/streambuf.h URL.o: /usr/local/gnu/include/g++-3/libio.h URL.h /usr/include/string.h URL.o: /usr/include/sys/feature_tests.h /usr/include/sys/isa_defs.h String.h Web.o: Web.h OrderedThreadedList.h Person.h String.h Web.o: /usr/local/gnu/include/g++-3/iostream.h Web.o: /usr/local/gnu/include/g++-3/streambuf.h Web.o: /usr/local/gnu/include/g++-3/libio.h URL.h /usr/include/string.h Web.o: /usr/include/sys/feature_tests.h /usr/include/sys/isa_defs.h Web.o: Provider.h SingletonProvidersList.h Web.o: /usr/local/gnu/include/g++-3/fstream.h ArrayOfPointers.h Web.o: /usr/include/ctype.h /usr/include/stdlib.h main.o: /usr/local/gnu/include/g++-3/iostream.h main.o: /usr/local/gnu/include/g++-3/streambuf.h main.o: /usr/local/gnu/include/g++-3/libio.h main.o: /usr/local/gnu/include/g++-3/fstream.h /usr/include/ctype.h main.o: /usr/include/sys/feature_tests.h /usr/include/sys/isa_defs.h main.o: /usr/include/stdlib.h SingletonProvidersList.h ArrayOfPointers.h main.o: Provider.h String.h URL.h /usr/include/string.h Person.h Web.h main.o: OrderedThreadedList.h 011064 The Web has a new member-http://www.mol.com/kkelly The Web has a new member-http://www.navasky.com/greg The Web has a new member-http://www.alpha.com/crash The Web has a new member-http://www.alpha.com/burn The Web has a new member -http://www.mol.com/zippy The Web has a new member -http://www.mol.com/aru The Web has a new member-http://www.mol.com/hdeitel The Web has a new member-http://www.wft.com/nikon The Web has a new member-http://www.wft.com/ebelford The Web has a new member-http://www.free.com/cereal The Web has a new member-http://www.mol.com/deitelp The Web has a new member-http://www.alpha.com/sw1 The Web has a new member -http://www.mol.com/zoomart The Web has a new member-http://www.mol.com/zsmith The Web has a new member-http://www.mol.com/asmith Removed: Emmanuel Goldstein Removed: Frank Navasky Removed: Joe Fox Removed: Kathleen Kelly Error:Frank Navasky Removed: Dade Murphy Removed: Kate Libby Removed: Iomega Maryland Online% 19.95 Alphabetical Network% 12.35 I Can't Believe It's An ISP% 2.34 Free ISP% 11.17 We're Free Too% 8.43 /