#include #include #include "biblio.h" main() { database *db; if ((db = database::open(DBNAME)) == NULL) { cout << "cannot open database " << DBNAME << endl; exit(1); } trans { persistent Author *a; persistent Paper *new_paper; char pnumber[MAX]; char title[MAX]; char author_name[MAX]; int aut_found = 0; // flag to tell if an author found in db // prompt for information to add paper cout << " ADD PAPER\n"; cout << "Enter the paper number: "; cin.getline(pnumber, MAX, '\n'); cout << "Enter title: "; cin.getline(title, MAX, '\n'); cout << "Enter name of corresponding author: "; cin.getline(author_name, MAX, '\n'); // If the author already exists, will create the new paper // and add it the the author's list of papers. // If the author doesn' exist, a warning will come to the // screen, but will still create the paper with the info given. for (a in Author) suchthat(strcmp(a->name,author_name)==0) { aut_found = 1; new_paper = pnew Paper(pnumber, title, author_name); a->add_paper(new_paper); new_paper->add_author(a); } if (!aut_found) { cout << "Warning!, that corresponding author doesn't exist.\n"; cout << " Adding paper with the information given.\n"; new_paper = pnew Paper(pnumber, title, author_name); } } // close trans } // close main