Question
Separate this Library Management System code into header and cpp files respectively into a library.cpp library.h , publication.cpp publication.h and main.coo and write a makefile
Separate this Library Management System code into header and cpp files respectively into a library.cpp library.h , publication.cpp publication.h and main.coo and write a makefile for these files to run on c++.
#include
class Publication { private: string title; string author; string copyright; string genre; string media; int target_age; string isbn; bool checked_out; string patron_name; string patron_phone; public: Publication(string title, string author, string copyright, string genre, string media, int target_age, string isbn) { this->title = title; this->author = author; this->copyright = copyright; this->genre = genre; this->media = media; this->target_age = target_age; this->isbn = isbn; } void check_out(string patron_name, string patron_phone) { checked_out = true; this->patron_name = patron_name; this->patron_phone = patron_phone; } void check_in() { checked_out = false; } bool is_checked_out() { return checked_out; } string to_string() { string output = "\"" + title + "\" "; output += "by " + author + ", " + copyright; output += " (" + genre + ") ISBN: " + isbn; if(is_checked_out()) output += " Checked out to " + patron_name + " (" + patron_phone + ")"; return output; } };
class Library { private: vector
void show_menu() { cout << "------------" << endl; cout << "(1) Add publication" << endl; cout << "(2) List all publications" << endl; cout << "(3) Check out publication" << endl; cout << "(4) Check in publication " << endl; cout << "-----------" << endl; cout << "(9) Help" << endl; cout << "(0) Exit " << endl; } int main() { Library library; int choice, target_age, index; string title, author, copyright, genre, media, isbn, patron_name, patron_phone; show_menu(); Publication *pub; while(true) { cout << "Enter your choice: "; cin >> choice; switch(choice) { case 1: cout << "Enter the title of publication: "; cin >> title; cout << "Enter the author for publication: "; cin >> author; cout << "Enter the copyright year for publication: "; cin >> copyright; cout << "Enter the genre of publication: "; cin >> genre; cout << "Enter the medium of publication: "; cin >> media; cout << "Enter the target age of publication: "; cin >> target_age; cout << "Enter the ISBN for publication: "; cin >> isbn; pub = new Publication(title, author, copyright, genre, media, target_age, isbn); library.add_publication(*pub); break; case 2: for(int i = 0; i < library.number_of_publications(); i++) cout << library.publication_to_string(i) << endl; break; case 3: cout << "Enter the index of the publication to checkout: "; cin >> index; if(index > library.number_of_publications() || index <= 0) cout << "Invalid publication index. We have only " << library.number_of_publications() << " publications." << endl; /*else if(library.publications[index].is_checked_out()) cout << "This publication readily checked out. Can't be granted to you." << endl; */ else { cout << "Enter the name of the patron: "; cin >> patron_name; cout << "Enter the phone number of patron: "; cin >> patron_phone; library.check_out(index, patron_name, patron_phone); cout << library.publication_to_string(index) << endl; } break; case 4: cout << "Enter the index of the publication to checkin: "; cin >> index; if(index > library.number_of_publications() || index <= 0) cout << "Invalid publication index. We have only " << library.number_of_publications() << " publications." << endl; /*else if(!(library.publications[index].is_checked_out())) cout << "This publication is not checked out. Can't check-in." << endl; */ else library.check_in(index); break; case 9: show_menu(); break; case 0: return 0; default: cout << "Invalid menu. Try again." << endl; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started