Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ You are to create two classes for this project, the properties of which are shown in the following UML diagrams. The Client will be

C++

You are to create two classes for this project, the properties of which are shown in the following UML diagrams. The Client will be able to add Book objects to a Bookstore object as well as other typical behaviors, such as removing items from the array.

Class: Book

Book

-title: string -isbn: unsigned int -vector: string -epublisher: string

+Book() +Book(int) +Book(string&, int, vector, string&) // Mutator Methods +setPublisher(string&): void +setISBN(int): void +setAuthor(int, string&): bool // Observer Methods +getTitle(): string +getISBN(): int +getAuthor(int): string +getPublisher(): string +toString(): string

Book Methods

  • Book(): Required if an array of Book objects is created

  • Book(unsigned): Creates a Book object with just the specified ISBN. Used by

    Client program.

  • Book(string&,unsigned,vector,string&): Fully initializes an object

  • setPublisher(string&): Modifies the objects Publishers name

  • setISBN(unsigned): Modifies the objects ISBN

  • setAuthor(int,string&): Modifies the specified authors name. The first parameter,

    Author number, must be in the range 1 to number of vector elements

  • setTitle(string&): Modifies the objects Title

  • getTitle(): Returns the objects Title

  • getPublisher(): Returns the objects Publisher name

  • getISBN(): Returns the objects ISBN

  • getAuthor(unsigned): Returns the objects specified author numbers name. The

    parameter, Author number, must be in the range 1 to number of vector

    elements

  • toString(): Returns a 4 line, string description of he object. Refer to Sample Run

for details of the required format

Class: BookStoreManager

BookStoreManager

-books: Book* -nmbrBooks: int -arrayCapacity: int -INIT_SIZE: staic const int -RESIZE_FACTOR: static const int

+BookstoreManager() + BookstoreManager(const BookstoreManager&) +~ BookstoreManager() // Mutator Methods +insert(const Book&): void +remove(const Book&): bool +removePublisher(string&): int // Observer Methods +isEmpty(): bool +capacity(): unsigned +listSize(): unsigned +search(const Book&): unsigned +toString(): string

BookStoreManager Details

  • The array for the Book objects is dynamically allocated. The Parameterless Constructor shall allocate Heap Memory for INIT_SIZE, Book objects. Define INIT_SIZE to be 2, the initial capacity of the array. When the full capacity is attained and another insert occurs, the array shall be automatically re-sized before the new Book item is inserted. Constant RESIZE_FACTOR, initialized to 2, determines the new capacity, being that value times the current capacity. Re-sizing must be accomplished without causing a memory leak.

  • nmbrBooks keeps track of the number elements currently utilized. It is affected by class methods insert, remove, and removePublisher.

    BookStoreManager Methods

  • BookstoreManager(): Parameterless Constructor. The initial array is established by allocationg Heap Memory for the array. The array is set empty by setting nmbrBooks to 0.

  • BookstoreManager(const BookstoreManager&): Class Copy Constructor. This method must be implemented since Heap Memory is allocated for the array.

  • ~BookstoreManager(): This method must also be implemented since Heap Memory is allocated for the array.

  • Operator=( const BookstoreManager&): This method must also be implemented since Heap Memory is allocated for the array

  • Insert(const Book&): This method will insert the specified Book object into the current array such that the sequence of Book objects in the array are sorted in ascending by the Book objects ISBN. Auto re-sizing of the array must occur if the array is at maximum capacity.

  • remove(const Book&): Searches the array for the element whose ISBN matches the ISBN of the specified Book object parameter. If found, the element is removed from the array, ensuring the ascending order of elements is maintained.

  • removePublisher(const string&): Searches the entire array for Book objects with the specified publishers name. All occurrences are removed, maintaining the ascending order of elements for all remaining array elements, if any. The method returrns the number of Book elements removed; 0: Publisher not found.

  • isEmpty(): Returns true if no elements utilized; false otherwise.

  • Capacity(): Returns the current capacity of the array.

  • listSize(): Returns the current number of utilized array elements.

  • search(const Book&): Searches the array for the element whose ISBN matches the ISBN of the specified Book object parameter. If found, the objects index value in the array is returned; otherwise, the item does not exist and -1 is returned.

  • toString(): Returns a string object describing all current Book elements in the array. The items will be listed in ascending order by ISBN; i.e. in ascending order of elements. Refer to the Sample Run for details.

Sample Output

Example #2: Adding "Book"s to the Bookstore Bookstore State: 
 1. The book store is not empty. 2. There are 5 books in the store. 3. Store Capacity: 8 
The current bookstore inventory: Book #1: Data Structures & Algorithm Analysis in C++ by Mark Weiss 132847 Pearson 
Book #2: Introduction to Programming Using Python by Daniel Liang 147231 Pearson 
Book #3: C++: Programming Basics by Nathan Clark 154296 CreateSpace 
Book #4: Data Abstraction & Problem Solving with C++ by Frank M.Carrano, Timothy M. Henry 165428 Pearson 
Book #5: Introduction to Algorithms by Thomas H.Cormen, Charles E. Leiserson 189352 MIT 
Example #3: Searching by ISBN... Target ISBN "147231" was NOT located. Target ISBN "154296" was NOT located. Target ISBN "154295" was NOT located. Target ISBN "132847" was NOT located. Target ISBN "189352" was NOT located. Target ISBN "165428" was NOT located. 
Example #4: Removing book(s) by ISBN... Test #1: 
 Removing ISBN: 189352 Status: 
 Target ISBN "189352" was was removed. The revised bookstore inventory: Book #1: Data Structures & Algorithm Analysis in C++ by Mark Weiss 
132847 Pearson 
Book #2: Introduction to Programming Using Python by Daniel Liang 147231 Pearson 
Book #3: C++: Programming Basics by Nathan Clark 154296 CreateSpace 
Book #4: Data Abstraction & Problem Solving with C++ by Frank M.Carrano, Timothy M. Henry 165428 Pearson 
Test #2: Removing ISBN: 165427 
Status: Target ISBN "165427" was not located. 
Example #5: Removing by Publisher... Test #1: 
 Removing Publisher: Pearson Status: 
 Target Publisher "Pearson" was was removed, eliminating 3 books. 
The revised bookstore inventory: Book #1: C++: Programming Basics by Nathan Clark 
154296 CreateSpace 
Test #2: Removing Publisher: Wiley 
Status: Target Publisher "Wiley" was not located. 
Test #3: Removing Publisher: CreateSpace 
Status: Target Publisher "CreateSpace" was was removed, eliminating 1 
book. The revised bookstore inventory: The bookstore is empty.

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

More Books

Students also viewed these Databases questions

Question

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

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago

Question

d. How will lack of trust be handled?

Answered: 1 week ago