Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Implement the following Store Shelf as described below: Each StoreShelf contains a number of items; Implement class StoreShelf with the following: 1. Three

image text in transcribed

Question 1: Implement the following Store Shelf as described below: Each StoreShelf contains a number of items; Implement class StoreShelf with the following: 1. Three private data member: (6 points) a. int maxSize b. int current (instantiate to 0) to track the current number of food items in the StoreShelf This attribute gets modified whenever an item is inserted or removed from the list. c. string *list a pointer to a dynamic array of strings that represent the food items on the shelf. 2. The following public member functions: (54 points): Use this pointer in all member functions of the class that take one or more parameters a. StoreShelf(int s): creates an empty StoreShelf and sets maxSize to s. b. -StoreShelf(): Deallocate list from the heap (use delete) c. isEmpty(), a boolean function that returns true if current ==0. and false otherwise. d. isFull(), a boolean function that returns true if current == maxSize, and false otherwise. e. int find(string item) returns the index of item if found in list, otherwise returns - 1. HINT: use string compare function from the string library. f. void insert(string item):this function does the following: i. Inserts item into the end of list StoreShelf, if the StoreShelf is not full and item does not exist in list. ii. If the item to be inserted is already in list, then print a message saying the item won't be inserted because it already exists in list. iii. If item is not in list, but list is full, then print a suitable message to say that the insert operation failed g. void printStoreShelf(): prints the items currently in the StoreShelf alongside their number. (3 points) h. Setter and getter for maxSize and getter for current . (5 points) i. float utilization() that calculates the percentage of used food items in a StoreShelf. (hint: utilization is 100*current/maxSize) //we need the division to be a floating-point division 3. Define friend function void remove(StoreShelf& shelf, int i): removes the ith item from list in shelf and shifts remaining items, only if list is not empty and if i is between 0 and current-1, inclusive

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

What is the formula to calculate the mth Fibonacci number?

Answered: 1 week ago

Question

Stages of a Relationship?

Answered: 1 week ago