Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pls solve the code. C++ Book class program, text includes the header file and 2 .cpp files: #pragma once /* * CECS 2223, Computer Programming

Pls solve the code. C++ Book class program, text includes the header file and 2 .cpp files:

#pragma once /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: Book.h * YOUR NAME, YOUR ID NUMBER * 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; }; /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: Book.cpp * YOUR NAME, YOUR ID NUMBER * 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). /* * CECS 2223, Computer Programming II Laboratory * Winter 2022, Sec. 05 * Date: December 19, 2022 * Topic: Lab 4 - Dynamic Memory * File name: lab04.cpp * YOUR NAME, YOUR ID NUMBER * 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

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago