#include #include #include using namespace std

#include
#include
#include

using namespace std;

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

#pragma region Helper functions

typedef enum
{
cl_Default,
cl_Red,
cl_Green
} Color;

typedef enum
{
st_Default,
st_Bold,
st_Underline
} Style;

// Printing with colors
void print(string str, Color color = cl_Default, Style style = st_Default)
{
string RESET = “u001B0m”;

string RESET_CODE = “0”;
string RED_CODE = “31”;
string GREEN_CODE = “32”;

string BOLD_CODE = “1”;
string UNDERLINE_CODE = “4”;

string styleCode = “”;

switch (color)
{
case cl_Red:
styleCode += RED_CODE;
break;

case cl_Green:
styleCode += GREEN_CODE;
break;

default:
break;
}

switch (style)
{
case st_Bold:
if (!styleCode.empty())
styleCode += ‘;’;
styleCode += BOLD_CODE;
break;

case st_Underline:
if (!styleCode.empty())
styleCode += ‘;’;
styleCode += UNDERLINE_CODE;
break;

default:
break;
}

if (styleCode.empty())
styleCode += ‘0’; // to use the default style

styleCode = “u001B” + styleCode + ‘m’;

cout input;
input = getch();

switch (input)
{
// Quit the program
case ‘q’:
case ‘Q’:
quit = true;
break;

case ‘p’:
case ‘P’:
{
print(“Enter the integer to push: “);
int item;
cin >> item;
stack.push(item);
break;
}

case ‘o’:
case ‘O’:
stack.pop();
break;

case ‘s’:
case ‘S’:
{
// creating a temp stack with the same capacity as the stack
// to back up the poped items, so we can restore them later
Stack temp = Stack(stack.capacity());

// print empty slots
for (int i = 0; i < stack.capacity() – stack.count(); i++)
{
cout