Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program please use this pointer and friend functions main.cpp: Driver StoreShelf.cpp: Class implementation StoreShelf.h: Class definition Implement the following Store Shelf as described below:

image text in transcribedimage text in transcribedimage text in transcribedC++ program please use this pointer and friend functions

main.cpp: Driver StoreShelf.cpp: Class implementation StoreShelf.h: Class definition 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. Store Shelf(int s): creates an empty StoreShelf and sets maxSize to s. b. StoreShelf(): Deallocate list from the heap (use delete) c. isEmpty0, 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 Write a driver program to test the class you have implemented, where you will: 1. Create an array of string objects named myfood_items of size 10 and fill it from the user. 2. Create a StoreShelf object named shelf with maxSize 10 and fill its first 5 items using the food items from myfood_items array. 3. Print the number of items in the shelf with the same item name as the last item name from myfood_items array 4. Use the friend function to remove the third item from list in shelf. 5. Print the utilization of the shelf to the screen. 6. Display the details of shelf

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

2. Eve really enjoys the science center.

Answered: 1 week ago

Question

please dont use chat gpt or other AI 4 8 5 .

Answered: 1 week ago