Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please finish the functions in hpp and int main function. Thank you so much! erConsumer Cla Beware of edge cases that arise from the array

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

please finish the functions in hpp and int main function. Thank you so much!

erConsumer Cla "Beware of edge cases that arise from the array being circular* In this class you will build a queue using the circular array implementation. Implement the methods of ProducerConsumer according to the following specifications. Note that in this queue implementation, the tail of the queue (queueEnd) is the index of the last item in the array and not the first available slot. By default, an empty queue will have head and tail indices (queueFront and queueEnd) set to -1 std::string queue[SIZE] A circular queue of strings in the form of an array. SIZE is initialized to a default value of 20 in ProducerConsumer.hpp int queueFront Index in the array that keeps track of the front item Index in the array that keeps track of the last iterm Constructor-set queueFront and queueEnd to-1 int queueEnd ProducerConsumer() bool isEmpty0 bool isFull) Return true if the queue is empty, false otherwise Return true if the queue is full, false otherwise void enqueue(std::string item) If the queue is not full, then add the item to the end of the queue and modify queueFront and/or queueEnd if appropriate, else print "Queue full, cannot add new tem" void dequeue() Remove the first item from the queue if the queue is not empty and modify queueFront and/or queueEnd if appropriate. Otherwise print "Queue empty, cannot dequeue an tem int queueSize() Return the number of items in the queue std:string peek0 If the queue is empty then print Queue empty, cannot peek and return an empty string. Otherwise, return the frontmost item in the queue ProducerConsum er main driver file Your program will start by displaying a menu by calling the menu() function which is included in the provided skeleton code. The user will select an option from the menu to decide upon what the program will do, after which the menu will be displayed again. Below are the specifics of the menu Option 1: Producer (Produce items into the queue- This is an enqueue operation This option prompts the user to enter the number of items being produced using the below print statement cout"Enter the number of items to be produced:" const int SIZE 20; class ProducerConsmer public: 15 16 17 18 19 20 21 ProducerConsumer); bool isEmpty); bool isFull); void enqueue(std::string player): void dequeue): int queueSize); int getQueueFront() return queueFront; int getQueueEnd () f return queueEnd; /I std: :string* getQueue) ( return queue; std::string peek(); 23 24 25 26 private: 27 28 29 30 ; 31 int queueFront int queueEnd; std::string queue [SIZE: /1 the queue // the index // the index 1 #include "Producerconsumer.hpp.. #include / you nay include more libraies as needed using namespace std; 4Purpose: displays a menu with options 5 @param none 6 areturn none 18 void menu() 9

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

What is an associative entity?

Answered: 1 week ago