#include #include "biblio.h" main() { persistent Author *a; persistent Author *author_to_add; persistent Paper *p; persistent Paper *the_paper; // the paper to which author will be added char name[MAX]; char pnum[MAX]; database *db; if ((db = database::open(DBNAME)) == NULL) { cout << "cannot open database " << DBNAME << endl; exit(1); } trans { cout << " ADD AUTHOR TO PAPER\n"; ///// get the author name //////////////////////// cout << "Enter the Author name: "; cin.getline(name, MAX, '\n'); // check to see if the name entered is in database // if the author was not found, bail. for (a in Author) suchthat(strcmp(a->name, name)==0) { author_to_add = a; } if ( !author_to_add) { cout << "Sorry. Was unable to locate that author.\n"; exit(1); } ///// get the paper number ////////////////////////// cout << "Enter the Paper Number: "; cin.getline(pnum, MAX, '\n'); // check to see if the pnumber for paper is in database // if unable to find paper, exit. for (p in Paper) suchthat(strcmp(p->pnumber, pnum)==0) { the_paper = p; } if ( !the_paper) { cout << "Sorry. Was unable to locate that paper.\n"; exit(1); } ///// now add the author in question to the paper. the_paper->add_author(author_to_add); // add paper to the author paper list, if not there already. if ( ! ((author_to_add->papers).contains(the_paper)) ) { author_to_add->add_paper(the_paper); } } }