Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Create a Stack Array Create a Stack Array of todo items using the following struct struct TodoItem { std::string todo; }; Do NOT add

C++ Create a Stack Array

Create a Stack Array of todo items using the following struct

struct TodoItem { std::string todo; };

Do NOT add a main method to any of your submitted files. DO write your own test drivers to test your code, but do not submit them. Your code needs to be readable, efficient, and accomplish the task provided. Make sure you delete your dynamically allocated memory in the appropriate methods! When working with array-based implementations, there is a max size available (set to 5 for this assignment in the header files). Display an error message if attempting to add to a full array: Stack full, cannot add new todo item. Or Queue full, cannot add new todo item. Note this does not apply to linked-list implementations. If the stack or queue is empty when you try to pop or peek it, display an error message: Stack empty, cannot pop an item. Stack empty, cannot peek. Queue empty, cannot dequeue an item. Queue empty, cannot peek. Make sure your code is commented enough to describe what it is doing. Include a comment block at the top of all .cpp files with your name, assignment number, and course instructor, and anyone you worked with. You must implement the functions as specified. You do not need any additional functions. Each .hpp file has one or more getter methods that are defined in the header. You do not need to implement these. Use the following code for your header files, and name them as indicated. DO NOT MODIFY.

Header file:

#ifndef HW4_TODO_STACKARRAY #define HW4_TODO_STACKARRAY #include struct TodoItem { std::string todo; };

const int MAX_STACK_SIZE = 5; class TodoStackArray { public: TodoStackArray(); bool isEmpty(); bool isFull(); void push(std::string todoItem); void pop(); TodoItem* peek(); int getStackTop() { return stackTop; } TodoItem** getStack() { return stack; } private: int stackTop; //the index in stack[] that will be popped next TodoItem* stack[MAX_STACK_SIZE]; }; #endif

You must use the header file. Please add comments and explain what you are doing and why. Will give thumbs up for correct functional code. Thanks

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Define promotion.

Answered: 1 week ago

Question

Write a note on transfer policy.

Answered: 1 week ago

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago