Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using c++ #pragma once /* * This file declares a class named Book */ // Which header files should be included? class Book { private:
Using c++ #pragma once /* * This file declares a class named Book */ // Which header files should be included? class Book { private: static int booksCreated; string title; int pages; int bookNumber; public: Book(); Book(Book&); ~Book(); void setTitle(string); void setPages(int); int getBooksCreated() const; string getTitle() const; int getPages() const; int getBookNumber() const; void printBook() const; }; /* * This file defines a class named Book */ // Which header files should be included? // The class variable is initialized to 0 // The default constructor initializes the title to the // empty string and pages to 0. bookNumber is initialized // to one more than the current value of booksCreated, // and booksCreated is incremented. // The copy constructor initializes bookNumber to one more // than the current value of booksCreated, and booksCreated // is incremented. It initializes the title and pages to the // same value as that of the title and pages of the parameter. // The destructor prints the phrase "Book number [number] has // been removed from the collection" // define the setters and getters // The printBook method uses printf to print the book's state // in a table ready format. It prints the book number aligned // to the left in a 3-space column, the number of pages also // aligned to the left in an 8-space column, and finally the // book's title (no column size). /* * This file implements a class named Book */ // Which header files should be included? int main() { // declare a pointer to a Book object named myCollection // and initialize it to the null pointer // declare an integer variable named books and initialize it to 0 // prompt the user for the amount of books using the phrase // "Enter the amount of books in your collection: ", and store // the value in the previously declared integer variable // The value used must be greater then 3 // Create a Book array using the number of books as the size // Implement a for iteration control structure to prompt the user // for the title and number of pages of each book in the collection // Create a Book object named copia using the copy constructor and // the reference of the second book in the array. // Change the title of copia to add Volume II at the end // print the following header using the same column sizes as in printBook // The data to be printed is the # symbol, PAGES, and TITLE // Using a for iteration control structure call the print method for each book // Release the memory allocated to the Book array // print a statement with your personal information using the phrase // "--- Program developed by [YOUR NAME], ID# [YOUR ID NUMBER] ---" // where the square brackets and the text within is substituted with your personal // information. Make sure to add a blank line before and after the phrase is printed. system(" pause"); // For Visual Studio only! return 0; }
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