int add(string data) { string nm = data; int id = 1; student *temp,*temp2; id = id+count; cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm; temp2 = head; temp = new student(nm,id); if(count == 0) { head = tail = temp; temp->setNext(NULL); count++; } else { tail->setNext(temp); tail=temp; temp->setNext(NULL); count++; } };
void add(string data) //this function will add a student to the linked list { ostringstream oss; student *now = head; student *end = tail; int i; while(now != NULL) { if(now->getName() == data) { cout<< "DUPLICATE:"<<data<<endl; return; } now = now->getNext(); } string nm = data; int id = 1; student *temp,*temp2; id = id+count; cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm<<endl; temp2 = head; temp = new student(nm,id); oss<<"ID00"<<id; string temps = oss.str(); temp->ID = temps; if(count == 0) { head = tail = temp; temp->setNext(NULL); count++; } else { tail->setNext(temp); tail=temp; temp->setNext(NULL); count++; } };
void addSpouse(string uid,string spouse1) //add spouse as person and as spouse to person { ostringstream oss; student *now = head; student *end = tail; int i; while(now != NULL) { if(now->getName() == spouse1) { cout<< "DUPLICATE:"<<spouse1<<endl; return; } now = now->getNext(); } string nm = spouse1; int id = 1; student *temp,*temp2; id = id+count; cout<<"Added: ID "<<setfill('0')<<setw(3)<<id<<" "<<nm<<endl; temp2 = head; temp = new student(nm,id); oss<<"ID00"<<id; string temps = oss.str(); temp->ID = temps; if(head == NULL) { head = tail = temp; temp->setNext(NULL); count++; } else { tail->setNext(temp); tail=temp; temp->setNext(NULL); count++; } student *here = head; student *found = NULL; student *before = head; while(here != NULL) { if (uid == here->getID()) { here->spouse = temp; temp->spouse = here; return; } else before = here; here = here->getNext(); } };