Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using C++ USING c++ B) (40 pts) class Library where a library contains several books that can be added or removed. Implement class Library with

using C++

image text in transcribed

USING c++

B) (40 pts) class Library where a library contains several books that can be added or removed. Implement class Library with the following: 1. Three private data members: a. int maxSize that represents the maximum number of books (i.e., unique book titles) that can be added to the library. Note that you can add any number of copies of a given book. b. int current that tracks the current number of unique book titles in the library. this attribute gets updated whenever a new book-title is removed or added to the library. C. Book *bookList, a pointer to a dynamic array of Books that represent all unique book titles in the library. 2. The private member function void resizeLibrary(int n), which resizes the dynamic array pointed to by the pointer bookList. a. The function should increase the array capacity by the amount of n. b. The function should validate that n is a positive integer. The function must preserve the data that was already in the list. C ++ C. 3. The following public member functions: Use this pointer in all member functions of the class that take one or more parameters. a. . Library(int n): that sets maxSize to n, allocates dynamic space of size maxSize, and makes the bookList pointer points to the allocated space. and sets current to 0. b. A copy constructor Library(const Library &) to properly copy data from one Library object to another. C. -Library(): Deallocates any dynamically allocated memory for an object. d. isEmpty(), a boolean function that returns true if the library is empty. and false otherwise. e. isFull(), a boolean function that returns true if the library is full, and false otherwise. f. int findBookBy Title(const string & title) returns the index of the book with requested title if found in the library, otherwise returns -1. HINT: use a string compare function (strcmp) from the string library. g. int findBookByISBN(string isbn) returns the index of the book with an ISBN that is equal to isbn if found in bookList, otherwise returns -1. h. void addBook(const Book & book): this function does the following: adds the book to the end of list bookList if the Library is not full and the book is not already exist in the list. If the book to is already in the list, then update the number of copies of that book (increment the current number of copies by the amount number_of_copies) If a book is not in the list, but the list is full, then resize the library pointed. by bookList to allow for 10 more books then add the book at the first available location (i.e., after all the books that already exist). void addBook(): this function is similar to the previous method but this one asks for all required book data to be input by the user of your program. j. Getters for maxSize and current data members. k. float capacityUsage() that calculates the percentage of the maximum number of books filled with books. The division must be a floating-point division 1. bool removeBookCopy(Library& libr, string isbn): if the book exists in the library then decrements the number of copies of the book by one If the number of copies becomes zero, the function must delete the book from the list by shifting left all book items on the right of the book to be removed. the function returns true if the book is found, otherwise, prints a proper message and returns false. 4. Define a global friend function void printLibrary(const Library & libr) that receives a Library object and prints the information of all the books in that library

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago