Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having trouble with the second part of an assignment, any help will be greatly appreciated. 2) Write a class called Store (filenames are store.h

I'm having trouble with the second part of an assignment, any help will be greatly appreciated.

2) Write a class called Store (filenames are store.h and store.cpp). A Store object should contain at least the following information: the amount of money in the store cash register and a book inventory list. There is no size limit to the inventory list, so it should be implemented with a dynamically allocated array. (This means you'll need an array of Book objects). You can add any public or private functions into the Store class that you feel are helpful. In addition to the Store class itself, you will also create a menu program to manage the inventory of books. However, the Store class will be able to do much of the work, as the Store member functions will be the interface between the menu program and the internally stored data (cash register and list of books).

Rules for the Store class:

All member data of class Store must be private

There should be no cin statements inside the Store class member functions. To ensure the class is more versatile, any user input (i.e. keyboard) described in the menu program below should be done in the menu program itself. Design the Store class interface so that any items of information from outside the class are received through parameters of the public member functions.

The list of Books must be implemented with a dynamically allocated array. There should never be more than 5 unused slots in this array (i.e. the number of allocated spaces may be at most 5 larger than the number of slots that are actually filled with real data). This means that you will need to ensure that the array allocation expands or shrinks at appropriate times. Whenever the array is resized, print a message (for testing purposes) that states that the array is being resized, and what the new size is. Example: "** Array being resized to 10 allocated slots".

Since dynamic allocation is being used inside the Store class, an appropriate destructor must be defined, to clean up memory. The class must not allow any memory leaks

You must use the const qualifier in all appropriate places (const member functions, const parameters, const returns, where appropriate).

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions