Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Note that this is a beginners C++ program and we can only use basic information*** Also, please explain how we input the inputs in order

***Note that this is a beginners C++ program and we can only use basic information***

Also, please explain how we input the inputs in order the get the outputs requested down below, Thank you!

Implement a shelf of numbers using your knowledge of classes and objects in C++. Your class should have the following things: 1. Class name Shelf 2. The data members of your class should be the following: Int array[size] where size is the maximum capacity of your shelf. Let your size be 3. Int top which points the index of the top most element on your shelf. All your data members will have the public access specifier. 3. The methods in your class will be the following: Bool insert (int item): this method will insert an item into your shelf and return True if the maximum capacity has not yet been reached, it will return False otherwise. If this returns False, then it means that you have reached the maximum capacity of your shelf, you need to print a message shelf is fully loaded. If it returns True, then print the message element inserted along with the element value. Int remove (): This method will return the top most element that is present in the shelf. You must check whether there are elements on your shelf before you remove elements. If your shelf is empty, then print the message Shelf empty cannot remove elements. Once this method is executed you must print the element that the function returns. Bool check_empty (): This method returns whether your shelf is empty or not. You need to make proper use of this function with the above two methods accordingly. Void print (): This method prints all the elements in the shelf. Make sure to check your shelf for elements before printing. If there are not elements print shelf empty. All your methods will have the public access specifier. 4. A public constructor which initializes the top of your shelf to -1. Create an object of type shelf and do the following operations: Insert(10) Insert(30) Insert(40) Print() Insert(50) Remove() Print() Remove() Remove() Remove() Print() Your output should be as follows: 10 inserted in the shelf 30 inserted in the shelf 40 inserted in the shelf The elements in the shelf are as follows: 10 30 40 Shelf is fully loaded cannot take in more elements 40 is removed from the shelf The elements in the shelf are as follows: 30 10 30 is removed from the shelf. 10 is removed from the shelf. Shelf is empty cannot remove elements Shelf is empty, cannot print Make sure that your code is well documented and indented. Also, all the submissions must in pdf format that are generated using the script process shown in lab containing the source code, compilation, and execution commands. Your program must run multiple times without having to run the program again.

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

Students also viewed these Databases questions