Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SEPERATE THIS CODE INTO 2 OR 3 CPP FILES AND HEADER FILE . THEN WRITE A MAKE FILE FOR THESE FILES SO IT CAN BE

SEPERATE THIS CODE INTO 2 OR 3 CPP FILES AND HEADER FILE . THEN WRITE A MAKE FILE FOR THESE FILES SO IT CAN BE COMPILED AND RUN ON C++11

#include #include #include using namespace std;

class Media { private: string title; string leading_actor; string director; int copyright; string genre; string media_type; string age_rating; int id; bool checked_out; string patron_name; string patron_phone; public: Media(string title, string leading_actor, string director, int copyright, string genre, string media_type, string age_rating, int id) { this->title = title; this->leading_actor = leading_actor; this->director = director; this->copyright = copyright; this->genre = genre; this->media_type = media_type; this->age_rating = age_rating; this->id = id; } 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 += "with " + leading_actor + ". Directed by " + director + ". " + std::to_string(copyright); output += " (" + genre + "). " + age_rating + ". " + media_type + ". ID: " + std::to_string(id); if(is_checked_out()) output += " Checked out to " + patron_name + " (" + patron_phone + ")"; return output; } };

class Video_Store { private: vector publications; public: void add_media(Media pub) { publications.push_back(pub); } void check_out(int media_index, string patron_name, string patron_phone) { publications[media_index-1].check_out(patron_name, patron_phone); } void check_in(int media_index) { publications[media_index-1].check_in(); } string publication_to_string(int media_index) { return publications[media_index-1].to_string(); } int number_of_media() { return publications.size(); } };

void show_menu() { cout << "=======================================" << endl; cout << " Video Rental Management System " << endl; cout << "=======================================" << endl; cout << "Media" << endl; cout << "------------" << endl; cout << "(1) Add Media" << endl; cout << "(2) List all Media" << endl; cout << "(3) Check out Media" << endl; cout << "(4) Check in Media " << endl; cout << "Utility" << endl; cout << "-----------" << endl; cout << "(9) Help" << endl; cout << "(0) Exit " << endl; } int main() { Video_Store videoStore; int choice, index, copyright, id; string title, leading_actor, director, genre, media_type, age_rating, patron_name, patron_phone; show_menu(); Media *pub; while(true) { cout << "Enter your choice: "; cin >> choice; switch(choice) { case 1: cout << "Enter the title of media: "; cin >> title; cout << "Enter the leading actor for publication: "; cin >> leading_actor; cout << "Enter the director for media: "; cin >> director; cout << "Enter the copyright year for media: "; cin >> copyright; cout << "Enter the genre of media: "; cin >> genre; cout << "Enter the medium of media: "; cin >> media_type; cout << "Enter the age rating of media: "; cin >> age_rating; cout << "Enter the ID for media: "; cin >> id; pub = new Media(title, leading_actor, director, copyright, genre, media_type, age_rating, id); videoStore.add_media(*pub); break; case 2: for(int i = 0; i < videoStore.number_of_media(); i++) cout << videoStore.publication_to_string(i) << endl; break; case 3: cout << "Enter the index of the media to checkout: "; cin >> index; if(index > videoStore.number_of_media() || index <= 0) cout << "Invalid media index. We have only " << videoStore.number_of_media() << " media." << 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; videoStore.check_out(index, patron_name, patron_phone); cout << videoStore.publication_to_string(index) << endl; } break; case 4: cout << "Enter the index of the media to checkin: "; cin >> index; if(index > videoStore.number_of_media() || index <= 0) cout << "Invalid media index. We have only " << videoStore.number_of_media() << " media." << endl; /*else if(!(library.publications[index].is_checked_out())) cout << "This publication is not checked out. Can't check-in." << endl; */ else videoStore.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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago