Stack

For this assignment you will create a Stack implementation , a menu driven test application ( like the lab ) and test files for all 3  data types

copy over all the files provided for you 
the files are in the usual place
use the -r option to get the testfiles directory as well



copy over your menu driven main from your lab where we used the std::stack implementation
get rid of 
#include <stack>
and include your Stack.h file 

you will replace the std::stack implementation with the one you will be creating
MAKE sure there are options for all the functions
full, empty, size, push , pop, capacity
model it off my example1, your main1 should look like that and have the same menu options



we have not talked about template classes yet so unlike the std::stack we will do it a different way
this is a very common method in standard C where we dont have template classes 

ELEMTYPE is a macro that will define the datatype that your stack should use. Top returns ELEMTYPE, Push adds and ELEMTYPE to stack
when you type make you will notice that ELEMTYPE is passed in so for each of the compiled programs ELEMTYPE means something different
g++ -Wall  -o runme_int -D LOGGING_ON main1.cpp easylogging++.o 
g++ -Wall  -o runme_string -D LOGGING_ON -D ELEMTYPE=string   main1.cpp easylogging++.o 
g++ -Wall  -o runme_fraction -D LOGGING_ON -D ELEMTYPE=CFraction main1.cpp easylogging++.o 

for runme_string ELEMTYPE is defined to string
for runme_fraction ELEMTYPE is defined to CFraction
for runme_int it is not set but we have a line in the Stack.h to set it to int if it does not have a value yet




The stack will be a dynamic design. The constructor allows the user to pass in a size for the container when it is created it will default to the value of 4. Since it has a default value it will work as your default constructor as well , like homework 4 DO NOT make a separate default constructor 


MAKE sure you test your stack by creating one and pass in a size to the constructor and make sure that the size is enforced.. 
.ie if you pass in 9 to the contructor make sure it allows insertion of up to 9 values. 
Test it by creating a stack and do not pass a size to the contructor it MUST default to a size of 4 and act accordingly 
(main2 and main3 do this , make sure to run ALL the examples)



Create ONLY 1 constructor and use a default parameter.

The stack will NOT re size OR grow as needed.

you will not use cout or cin ANYWHERE in your stack class. 
any cout or cin operations should happen in the main test application
Log the start and end of all functions

DO NOT PUT ANY LOGIC TO PREVENT A FUNTION BEING CALLED in your main
if the menu option for add or delete is chosen call the cooresponding function 
regardless if the container is full or empty



File: Stack.h 

#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"


#ifndef ELEMTYPE  // only do the following define if its not already defined, we may have already defined it to be string or fraction when we compile
#define ELEMTYPE  int
#endif

class Stack
{
	private:
		ELEMTYPE * data;
		int TopIndex;
		int capacity;



// you will need a constructor it will allow the user to pass in the size/capacity of the container as the only parameter
// have this default to the value of 4
// set the data* to an array of the size passed in
// set capacity to size passed in 
// set TopIndex =0; this both how many items are in our stack and the next index to add a value to



// a destructor that cleans up data

// a public function "Empty" that returns true or false if the container is empty



// a public function "Full" that returns true or false if the container is full



// a public function "Capacity" that returns the capacity of the stack



// a function "Size" that returns the number of elements currently in the stack



// a public function "Push" that allows a value of ELEMTYPE to be added or  "pushed" into the stack, returns 
// true or false if push operation was successful
// insert value into array at index  TopIndex
// increment TopIndex



// a public function "Pop" that will remove or "pop' a value  from the stack
// true or false if pop operation was successful
// decrement TopIndex



// a public function "Top" that returns a reference to the top value (ELEMTYPE)  on the stack
// if the stack is empty throw "Stack Empty"



// a public ToString() function that matches the examples output







};



You will complete main1.cpp, it should be bascially the same as your main from lab make sure mains2,3,4 compile and work as is, they are the example_test_size1 - 3 when complete your code should perform EXACTLY like the examples example_int example_string example_fraction example_test_size1 example_test_size2 example_test_size3 create a test file for each data type and use it to test your code your test file should work with both the example and your code start simple then make your testfiles more complex... try to break your stack.. add even if its full delete when its empty I will absolutely do it when I grade your assignments I WILL grade your homework with a testfile of my own.