Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ASSUME EVERYTHING IS IMPLEMENTED CORRECTLY I JUST NEED THE MAIN... JUST THE MAIN JUST THE MAIN NOT THE LIBRARY OR THE BOOK I JUST NEED

image text in transcribed

image text in transcribed

image text in transcribed

ASSUME EVERYTHING IS IMPLEMENTED CORRECTLY

I JUST NEED THE MAIN...

JUST THE MAIN

JUST THE MAIN

NOT THE LIBRARY OR THE BOOK

I JUST NEED Q2

DON'T SOLVE Q1

DON'T SOLVE Q1

JUST Q2 I WILL UPVOTE

e with the following: Names and IDs of all group members A brief description of cach team member contributions What did you find most challenging about this assignment Any other notes you would like us to know about your submission Question 1/55 pts): Implement the following classes A) (15 pts) class Book with the following members: 1. private members: a. book title (string) b. book ISBN (string) c. book first author(string) d. book number_of_coples (int) Note: for this assignment, a book ISBN can be any string (such as 978-3-16) and it should be unique for each book 2. public members: a. A parameterized constructor with default arguments for all data members: for the string data members and for the numeric data member. The constructor should initialize all data members properly b. setters and getters for all data members. The setter for the number of coples should validate that the number is greater than or equal to zero. and for strings to be non- empty C. The member function updateBookNunCopies (int n) to update the number of copies of a book. The function receives an integer value (can be negative or positive) and updates the current number of copies only If the result of adding that value to the current count is zero or more, otherwise, it prints a proper error message 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 (ieunique 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 uxlated 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. 2. The function should increase the array capacity by the amount of n. b. The function should validate that is a positive integer. C. The function must preserve the data that was already in the list. 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 naxSize, and makes the bookList pointer points to the allocated space and sets current to o b. A copy constructor Library(const Library &) to properly copy data from one Library object to another. c. -Library(): Dealexcates any dynamically allocated memory for an object. 2 d. isempty(), a boolean function that returns true if the library is empty, and a false otherwise e isFull(), a boolean function that returns true if the library is full, and false otherwise f. int findBookByTitle(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. 5. int findBookByISBN(string isbn) retums the index of the book with an ISBN that is equal to Isbn if found in booklist, otherwise returns -1. 2. The private member function void resizeLibrary(int n), which resizes the dynamic array pointed to buy 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. C. The function must preserve the data that was already in the list. 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 ton, allocates dynamic space of size maxSize, and makes the booklist pointer points to the allocated space and sets current too. 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. 2 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 findBookByTitle(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) retums 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 t booklist to allow for 10 more books then add the book at the first available location (i.c., after all the books that already exist). I. 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 bool renoveBookCopy(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 txxxk 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 a receives a Library object and prints the information of all the books in that library . : . Note: You may implement additional methods if you need to 3 message and retums 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 Note: You may Implement additional methods If you need to 3 Question 2 (35 pts): Write a driver program to test the classes you have implemented as follows Note: Do not reimplement functionalities that are already implemented in classes Book and Library, 1. Create a dynamic array of Book objects named myBooks_itens of size 5. 2. Fill myBooks_itens with proper data from the user for 5 different books, 3. Create a Library object named lib with a naxSize of 6. 4. Fill the first 5 items of the library Lib using the book items from my Books_items array. 5. Create a dynamic object of type Book using the data of the second object in the array myBooks itens 6. Delete the dynamic array pointed to by my Books_itens 7. Add 3 more copies of the book from Question point 5 to library lib 8. Add two more unique books by calling addBooko 9. display the details of all books in lib 10. call a proper function to print the current size of the library 11. Print the usage-percentage of the booklist in lib using a proper function call 12. remove all copies of the book from Question2-point 5 13. Once again, Display the details of all the books in lib. 4

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

Students also viewed these Databases questions