Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ a Question 1(55 pts): Implement the following classes: A) [15 pts) class Book with the following members 1. private members: a. book title (string)

c++
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
a 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_copies (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 o 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 copies should validate that the number is greater than or equal to zero and for strings to be non-empty. c. The member function updateBookNumCopies(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 (i.c., 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. cBook "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 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 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. d. Emptyllabolatot test the library ismety and the otherwise ei) a bean function thermal therary is full the therwise tintfindooyeconst string & tees of the book with regrested i found in the beach. HINT compare for from the nyaring in the index of the swithan 150 equal to be found in list therwise team voldado con Book & books action des the fol adds the book to leende booklist the Library not full and the book does not already existe the book to the whole theme of copies of book in the center of cuples by the amount of complet Ma book is not in the but the last three the library pointed by booklist to for more books the the book at the first aitable in Geher all the best weld dook his function or to the plant method but the for all required for it to be the wrotyw prom Getters formes Sand current data member o capacitysage that the age of the maximum number of books filled with books. The divisione a fling points on bool removeBookCopyright the book can in the then decremees the number of copies of the book by the number of copies becomes more, the function est delete the book from they shinglefes the right of the book to be removed the function relate the book is found otherwise, ris proper event the Deine alobal friend function vold pritibranycost Library & libr) that receives tibary object and is the information of the book is to be Note How may implement al method if you need to Question 2.35 pts. Write a deher program to test the cases your first implemented and follows Note: the nat teimplement functionalities that we stay implemented actases Book and Library 1. Create a dynamic any of Book objects named myBooks_toms of size 5 2. Fillmylooks dem with proper data from the werfer different boots Create a Library object named with a maxSize of 6 4. Fill the fosse of the bathrooms from mysteme 5. Create a namic object of type Rock on the data of the second set in the ray mookte 6 Delete the dynamic any pointed to by mylooks_home 7. Add more copies of the book from point Sebaya Add to more books by click display the details of all books 10. call a propes function to print the current store bar 11. Pithe usage percentage of the booklistinning a proper function call 12. remove al copies of the book from Question points 1). Once again, Display the detail of the books in Questions internet the following classes Atels Bath the following members 1. private members kiestring hock ISA (sing but horring dhoomber_of_celest Note for the book is can be string och 878-3-93 should be wie for each to 2. publicember Awametered contract with default arguments for all member for the da members and for the data member the cold wite mengely wten and getters for all data formers. The they for the umber of copies should are that the number greater than or equal to and forms to be the member function updateBookNumCopii to update the bere copies of a book. The function reches anges con begane pole and the recopil the fight thermore, there were B) te plass Library where they can look that can be added or removed Implement com Libry with the following The Gramener Se press the maximum number of books denique boeke can be set to the ray. Note that you can add an under of copies of a poc nt current that tack the care number of unique book is in the beach atte pois piedeva new hoe meer med to the Book on pinter to a dynamics of Books three book es the way 2. The private manter onvold Library in which the dancy pointed to by the pointer bootie The fonction head increase the capacity by the amount of The function house penger The functional presence the data was in the fint The fing public memberi Les function sheen that contact Library is that sets maStore to see more of sine massim. makes the bodistes ponts to the located and sets current Acry commuter Library conut Library to properly copy data from one Library her cyDefectes dynamically located memory for anotect & poloection et erary is more therese e adolean function the returnee Mary is Mother in fidoyilen string return the index of the book with requestedet found in the bare here te HN compare function from the string bary. winyingine tendes of the ISBN quan found in booklist otherwiseret vold Bont Book & tones theo the book to the end of the booklist the Library and the Beck does normally exhat in the but of the book to lay in the then update the heroes of that book cement the current number of copies by the manner a book is not in the Int, but the father they med> bookListelow for more books then the book at the festlane locatie hthebes that are void Book this function or to the previous method be the ones for beint by the set of your Geef maand current commen Lout capacityUsage tatoutes the role of the of bekled the book. The defined bool removeBookCopylatrings . e is a boolean function that returns true if the library is full and tabe otherwise tidBookBythecorating the return the index of the Wok with requested title if found in the library, otherwise reunes-1. HINT:e a string comme danction strompirom the stringitary #int findBookyASEN string isbn) returns the index of the book with an ISBN that is equal to is found in bookLiotherwise retums-1. vold add ookconst Book & books the function does the following . and the book to the end of list booklis if the Library is not full and the book does not already exist in the list of the book to really in the then update the number of copies of that book (increment the current number of copies by the amount and copies a book is not in the list, but the int in full, then resize the Ibrary pointed by booklist to w for 10 more books then add the book the first wailable in le, after all the books that are why void addtookly: the function is comitato me presion method but this one is for all required book data to be input by the use of your program Getters for males and current data members float capacityUsage that calculate the percentage of the maximum of books filled with books. The division is te afloating point division bool removeBookCopy(string isbn if the book exists in the library then decremenes the number of copies of the book by one If the number of copies becomes zemn, the functie delete the book from the list by shifting left all book items on the right of the book to be removed the functioners in the book is found, otherwise prints a proper message and return false. 4. Delinea global friend function void printLibrary(const Library delibe) to receives Library object and press the information of all the book that Ibrary Note: You may implement additional methods if you need to Question 2 635 pts : Write a drher program to test the days 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 Books med myBooks_tems of size 5 2. Pill myBeoks_tems with proper data from the uses for different books 3. Create a Library object named sb with a maksize of 6. 4. Fill the test lens of the brary libing the book sens from my Bookstems may 5. Create a dynamic object of type Book oving the data of the second object in the artay myBooks_Items 6. Delete the namic array pointed to by myBooks_tems 7. Add more copies of the book from Question2-points to library lib 8. Add two more unique books by calling addock) 9 display the details of all books in lib 10 cali a proper function to print the current size of the library 11. Print the percentage of the booklist in libing a proper fanctional 12. remove all copies of the book from Question point 13. Once again, Display the details of all the books in lb

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 And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

3. Identify challenges to good listening and their remedies

Answered: 1 week ago

Question

4. Identify ethical factors in the listening process

Answered: 1 week ago