Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This file needs to be coded in C++. The only files that can be edited are Encyclopedia.h and Encyclopedia.cpp. The rest of the files are

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

This file needs to be coded in C++. The only files that can be edited are Encyclopedia.h and Encyclopedia.cpp. The rest of the files are un-writeable.

14.14 LAB: Book information (overriding member functions) Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a PrintInfo() function that overrides the Book class' PrintInfo() function by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes. Ex. If the input is: The Hobbit J. R. R. Tolkien George Allen & Unwin 21 September 1937 The Illustrated Encyclopedia of the Universe James W. Guthrie Watson-Guptill 2001 2nd 1 the output is: Book Information: Book Title: The Hobbit Author: J. R. R. Tolkien Publisher: George Allen & Unwin Publication Date: 21 September 1937 Book Information: Book Title: The Illustrated Encyclopedia of the Universe Author: James W. Guthrie Publisher: Watson-Guptill Publication Date: 2001 Edition: 2nd Number of Volumes: 1 File is marked as read only Current file: Book.h 1 #ifndef BOOKH 2 #define BOOKH 3 4 #include 5 6 using namespace std; 7 8 class Book 9 public: 10 void SetTitle(string userTitle); 11 12 string GetTitle(); 13 14 void SetAuthor(string userAuthor); 15 16 string GetAuthor(); 17 18 void SetPublisher(string user Publisher); 19 20 string GetPublisher(); 21 22 void SetPublicationDate(string userPublicationDate); 23 24 string GetPublicationDate(); 25 26 void PrintInfo(); 27 28 protected: 29 string title; 30 string author; 31 string publisher; 32 string publicationDate; 33 }; 34 35 #endif mmm File is marked as read only Current file: Book.cpp 9 1 #include "Book.h" 2 #include 3 4 void Book::SetTitle(string userTitle) { 5 title = userTitle; 6} 7 8 string Book::GetTitle() { return title; 10 } 11 12 void Book::SetAuthor(string userAuthor) { 13 author = userAuthor; 14 } 15 16 string Book::GetAuthor() { 17 return author; 18 } 19 20 void Book::SetPublisher(string user Publisher) { 21 publisher user Publisher; File is marked as read only Current file: Book.cpp 20 void Book::SetPublisher(string userPublisher) { 21 publisher = user Publisher; 22 } 23 24 string Book::GetPublisher() { 25 return publisher; 26 } 27 28 void Book::SetPublicationDate(string userPublicationDate) { 29 publicationDate = user PublicationDate; 30 } 31 32 string Book::GetPublicationDate() { 33 return publicationDate; 34 } 35 36 void Book::PrintInfo() { 37 cout 3 4 // Define functions declared in Encyclopedia.h| File is marked as read only Current file: main.cpp 1 #include "Book.h" 2 #include "Encyclopedia.h" 3 #include 4 #include 5 using namespace std; 6 7 int main(int args, char* argv[]) { 8 Book myBook; 9 Encyclopedia myEncyclopedia; 10 11 string title, author, publisher, publicationDate; 12 string eTitle, eAuthor, ePublisher, ePublicationDate, edition; 13 int numVolumes; 14 15 getline (cin, title); 16 getline(cin, author); 17 getline (cin, publisher); 18 getline (cin, publicationDate); 19 20 getline(cin, eTitle); 21 getline(cin, Author); 22 getline (cin, ePublisher); NN File is marked as read only Current file: main.cpp getline(cin, Author); getline (cin, ePublisher); getline (cin, ePublicationDate); getline (cin, edition); cin >> numVolumes; 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 myBook.setTitle(title); myBook.setAuthor(author); myBook.SetPublisher(publisher); myBook.SetPublicationDate (publicationDate); myBook.PrintInfo(); my Encyclopedia. SetTitle(eTitle); my Encyclopedia. SetAuthor(eAuthor); my Encyclopedia.SetPublisher(ePublisher); my Encyclopedia.SetPublicationDate(ePublicationDate); my Encyclopedia.setEdition(edition); my Encyclopedia. SetNumVolumes (numVolumes); my Encyclopedia.PrintInfo(); return 0; }

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago