Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I have a C++ code project that I need help with. It involves implementation of Stack and Linked List. The program should check if

Hi I have a C++ code project that I need help with. It involves implementation of Stack and Linked List. The program should check if a string of left and right curly braces that is entered by user is balanced or not. The program will run in two modes, parser and test mode and the user will choose at command line by entering either p or t. In Test the program will check if the new stack is empty, if a push on the stack makes it not empty, if popping everything in the stack makes it empty and if the copy constructor copies everything in the right order. The tests can be run in any order. After the Stack is checked to be working correctly then the parser mode will check if the string entered is balanced. The stack tester class will run tests to confirm that it works, prints the test that is running and if it passed or failed. Lastly if you can make sure there is no memory leaks using deconstructor. I will include some of the files and how they should look, if you can show the full header and .cpp files complete code that would be very helpful. Thank You!

Here is an example of the header file for the stack:

class StackOfChars { private: Node* m_top; public: StackOfChars(); StackOfChars(const StackOfChars& orig); ~StackOfChars(); void operator=(const StackOfChars& rhs); void push(char entry); void pop(); char peek() const; bool isEmpty() const; }; #endif

Here is example of linked list .h file:

#ifndef NODE_H #define NODE_H class Node { private: char m_entry; Node* m_next; public: Node(char entry); char getEntry() const; void setEntry(char entry); Node* getNext() const; void setNext(Node* next); }; #endif

Here is example of tester class:

class StackTester { public: StackTester(); void runTests(); private: //Creates an empty stack and verifies isEmpty() returns true void test01(); //Creates an empty stack pushes 1 value, verifies isEmpty() returns false void test02(); //Creates an empty stack, then pushes once, pops once, and verifies isEmpty returns true void test03(); //more test methods };

Here is what the test output should look like:

$>./lab -t Test: stack is empty: PASSED Test: Push on empty stack makes it non-empty: PASSED Test: Popping all all elements makes stack empty: FAILED Test: Copy constructor copies all elements in correct order: FAILED

Example of parser output:

$>./lab -p Enter your sequence: {} Sequence is balanced.

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_2

Step: 3

blur-text-image_3

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

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions