Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#pragma once #include #include using std::cout; using std::endl; using std::string; class Book { private: string title; string author; int ISBN; bool isCheckedOut; string checkedOutBy; public:

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

#pragma once #include #include using std::cout; using std::endl; using std::string; class Book { private: string title; string author; int ISBN; bool isCheckedOut; string checkedOutBy; public: //Constructor Book(string t = "N/A", string a = "N/A", int i = -1) { title = t; author = a; ISBN = i; isCheckedOut = false; checkedOutBy = ""; } //Getters string getTitle() { return title; } string getAuthor() { return author; } int getISBN() { return ISBN; } bool getStatus() { return isCheckedOut; } string getCheckedOutBy() { return checkedOutBy; } //Setters void setTitle(string new_t) { title = new_t; } void setAuthor(string new_a) { author = new_a; } void setISBN(int new_i) { ISBN = new_i; } // If the book is checked out, return false, //otherwise, set the checked out status to //true and update the name of the user that //checked out the book. bool checkOutBook(string n) { if (isCheckedOut == true) return false; else { isCheckedOut = true; checkedOutBy = n; return true; } } void returnBook() { isCheckedOut = false; checkedOutBy = ""; } void outputBook() { cout author = obj.author; this->title = obj.title; this->ISBN = obj.ISBN; this->checkedOutBy = obj.checkedOutBy; this->isCheckedOut = obj.isCheckedOut; return *this; } };

#include "CatalogClass.h" #include using std::cin; using std::getline; void populate_catalog(Catalog& my_catalog); int display_menu(); int main() { Catalog my_catalog; populate_catalog(my_catalog); cout = 1 && choice > choice; if (choice 8) { cout 8); return choice; } void populate_catalog(Catalog& my_catalog) { Book temp_obj; temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Sorcerers Stone"); temp_obj.setISBN(98346); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Chamber of Secrets"); temp_obj.setISBN(19285); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Prisioner of Azkaban"); temp_obj.setISBN(88224); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Goblet of Fire"); temp_obj.setISBN(21001); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Order of Phoenix"); temp_obj.setISBN(66754); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Half-Blood Prince"); temp_obj.setISBN(50125); my_catalog.addBook(temp_obj); temp_obj.setAuthor("J.K. Rowling"); temp_obj.setTitle("Harry Potter and the Deathly Hallows"); temp_obj.setISBN(68304); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("The Lion, the Witch, and the Wardrobe"); temp_obj.setISBN(45336); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("Prince Caspian"); temp_obj.setISBN(76689); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("The Voyage of the Dawn Treader"); temp_obj.setISBN(34982); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("The Silver Chair"); temp_obj.setISBN(45993); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("A Horse and His Boy"); temp_obj.setISBN(42398); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("The Magician's Nephew"); temp_obj.setISBN(39203); my_catalog.addBook(temp_obj); temp_obj.setAuthor("C.S. Lewis"); temp_obj.setTitle("TheLast Battle"); temp_obj.setISBN(56342); my_catalog.addBook(temp_obj); temp_obj.setAuthor("E. B. White"); temp_obj.setTitle("Charlotte's Web"); temp_obj.setISBN(47851); my_catalog.addBook(temp_obj); temp_obj.setAuthor("F. Scott Fitzgerald"); temp_obj.setTitle("The Great Gasby"); temp_obj.setISBN(11934); my_catalog.addBook(temp_obj); temp_obj.setAuthor("S. E. Hinton"); temp_obj.setTitle("The Outsiders"); temp_obj.setISBN(72331); my_catalog.addBook(temp_obj); /* Feel free to add more books below to experiment with the catalog class! */ }

Have to make it where

Part 1 Instructions In the previous assignment, we created a class called "Book, which stored basic information about a book at a library. The program used this class to create sample book objects to store information about popular novels. In this program, we are going to build a new class called "Catalog, which will be used to store and manage books in the library. The program should support the following menu commands: 1. Search Catalog a. By Title b. By Author c. By ISBN 2. Add New Book 3. Get Book Status 4. Check in a Book 5. Check Out a Book 6. Exit Catalog -books: Book pointer -next_slot: int -capacity: int Catalog(init_size: int) ~Catalog() Getters and Setters +getNumBooks(): int -emptyCatalog(): void Utility Methods +getBookBy Title(title:string, book: Book&): bool +listBooksByAuthor(author:string): bool +getBookByISBN(isbn:int, book:Book&): bool +getBookStatus(isbn:int, checked OutBy:string&): bool +checkOutBook(isbn:int, name:string): bool +checkInBook(isbn: int): bool +addBook(new_book: Book): void +outputCatalog(): void -growCatalog(): void Descriptions of Notable Methods 1. listBookBy Author - prints out a list of books written by the author. Returns true if the author has at least 1 book in the catalog and false if not. 2. getBookBy - These methods search the Catalog for a book matching the specified attribute. The "book" parameter is a reference parameter used to pass the book back by. If the book is found, assign the book parameter to the book found and return true. If not found, do not assign the book object to anything and return false. 3. getBookStatus - Gets the status of a book in the library. Returns true if the book is checked out, false otherwise. Also returns the person's name that has the book checked out via reference variable if the book is checked out. The string will be empty if the book is not checked out. 4. checkOutBook - Searches the catalog of the book for the ISBN number and checks the book out, if the book is found and is not checked out. Returns true if it successfully checks the book out, false if it does not. 5. checkInBook - Checks in a book in the catalog. Returns true if the book is found and checked in, and false otherwise. 6. addBook - Adds a book to the catalog. Takes in a book object and then copies that book object into the next available slot. If the "books array is at capacity, then growCatalog() should be called. 7. outputCatalog - Prints out the entire catalog of books. Calls the outputBook method from each book. 8. growCatalog - This function will be provided to you in the Appendix. This function should be copied into your Catalog class definition. Used to increase the number of elements in the "books" array to support more books. 9. emptyCatalog - This function deallocates all book objects in the "books" array. Use delete[] on the array to achieve this

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

Question

List out some inventory management techniques.

Answered: 1 week ago

Question

Choosing Your Topic Researching the Topic

Answered: 1 week ago

Question

The Power of Public Speaking Clarifying the

Answered: 1 week ago