Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Define a class, named BookInfo, that contains (1) three private members: title (a string), author (a string), yearPublished (an integer) (2) the corresponding accessors

image text in transcribedimage text in transcribed

C++

Define a class, named BookInfo, that contains (1) three private members: title (a string), author (a string), yearPublished (an integer) (2) the corresponding accessors and mutators for the above member variables in the public section string getTitle(); return the title of a book string getAuthor0; -- retum the author int getYearPublished(): - return the year of publication void setTitle(string); - set the title of a book via the input string parameter void setAuthor(string): -- set the author void setYear Published (int): - set the year of publication (3) two constructors the default constructor that sets both the title and author of the book as 'Unknown' and the year of publication as 2021. an overloaded constructor that takes three parameters as input in the order of (string in Title, string inAuthor, int year) and initialize the corresponding member variables of the book object (4) a void printout() function that outputs the information of a book in the following format: Title: , Author: In the main() function, declare a BookInfo object and set its title to be 'The Hobbit', its author to be 'J.R.R. Tolkien', and its yearPublished as '1937". Then outout this book information as: Title: The Hobbit Author: J. R. 3. Tolkien Year of Publication: 1937 Note: Please do not hard-code the above outout. Instead, you should call the accessors to get the information for output. declare a BookInfo array with three books at places where appropriate to make the code work The main is commented in the initial template to allow you to test the class first (Test cases 4-8). After passing these test cases, string getTitle(): --return the title of a book String getAuthor:retum the author int getYearPublished: - return the year of publication void setTitle(string): -- set the title of a book via the input string parameter void setAuthor(string); - set the author void setYearPublished (int); -- set the year of publication (3) two constructors the default constructor that sets both the title and author of the book as 'Unknown' and the year of publication as 2021. an overloaded constructor that takes three parameters as input in the order of (string in Title string in Author, int year) and initialize the corresponding member variables the book object (4) a void printout() function that outputs the information of a book in the following format: Title: the title of the ocok, Author: the author of the bock, Year of Pubrication: In the main() function, declare a BookInfo object and set its title to be 'The Hobbit", its author to be 'J.R.R. Tolkien', and its yearPublished as "1937". Then output this book information as: Title: The Hobbit Author: J. R. R. Tolkien Year of Publication: 1937 Note: Please do not hard-code the above output. Instead, you should call the accessors to get the information for output declare a BookInfo array with three books at places where appropriate to make the code work mainis in the initial template to allow you to class first (Testo 4-8). After passing these cases, uncomment and complete the main. Uncommenting the main while your class is still incomplete will lead to compiler errors. Hint: both the title and the author's name of a book may contain one or more whitespaces, thus, you should use getline() for their input. Also, remember to call cin.ignore() before the get line() function if you use a cin>> statement before the getline to ensure the correct input

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_2

Step: 3

blur-text-image_3

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

What challenges does it face? Who are the competitors?

Answered: 1 week ago

Question

6. Discuss the steps involved in conducting a task analysis.

Answered: 1 week ago

Question

8. Explain competency models and the process used to develop them.

Answered: 1 week ago