#include #include "biblio.h" ///////////////////////////////////////////////// //methods for Person ///////////////////////////////////////////////// void Person::print_person() { cout << "Name: " << name << " Address: " << address << " Email: " << email << endl; } ///////////////////////////////////////////////// //methods for Author ///////////////////////////////////////////////// //use the constructor from the Person object to create a new author. Author::Author(char* n, char* a, char* e) : Person(n, a, e) {} // adding a paper to an author void Author::add_paper(persistent Paper *new_paper) { papers.add(new_paper); } // will remove a paper from an author given the pnumber. void Author::remove_paper(char* pnum) { persistent Paper *pp; papers.reset_iteration(); while(pp = (persistent Paper*)(papers.next_iteration()) ) { if( !strcmp(pp->pnumber, pnum) ) { papers.remove( (persistent Element*)pp ); } } } // print out author info. void Author::print() { persistent Paper *p; int has_papers = 1; cout << name << ", " << address << ", " << email << endl; cout << " Papers:\n"; // print the corresponding papers to each person papers.reset_iteration(); while (p = (persistent Paper*)papers.next_iteration() ) { p->print_details(); has_papers = 0; } if (has_papers) { cout << " none\n"; } } ///////////////////////////////////////////////// // methods for Paper ///////////////////////////////////////////////// // Paper constructor. Paper::Paper(char* p, char* t, char* ca) { strcpy(pnumber, p); strcpy(title, t); strcpy(corr_author_name, ca); strcpy(status, "submitted"); } // called from print author void Paper::print_details() { cout << " " << pnumber << ", " << "\"" << title << "\" \n"; } void Paper::print_authors() { persistent Author *pa; int author_exists = 0; // flag whether associatd with real author in db authors.reset_iteration(); while (pa = (persistent Author*)authors.next_iteration() ) { author_exists = 1; if ( strcmp(pa->name, corr_author_name)==0 ) { cout << "(" << pa->name << ") "; } else { cout << pa->name << " "; } } if (!author_exists) { cout << "(" << corr_author_name << ")"; } cout << endl; } void Paper::print() { cout << "- " << pnumber << ", " << "\"" << title << ",\" "; print_authors(); } void Paper::change_status(char* new_status) { strcpy(status, new_status); } void Paper::add_author(persistent Author *new_author) { authors.add(new_author); }