Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, need help with testing my program. I have everything programed just can't figure out how o implement proper testing for the stack. All test

Hello, need help with testing my program. I have everything programed just can't figure out how o implement proper testing for the stack. All test code is going into main.cpp. Here are the instructions for testing:

main.cpp : your main() function and nothing else. main() is simply your test program. main() is where you will thoroughly test your stack in automated fashion (no user input). Do whatever you need to do in main() to prove your stack works fully. You must test every possible operation in every possible combination and explicitly show your stack is fully functional and can handle underflow, overflow, incorrect input, multiple random operations in every combination.

Here is my code:

****MAIN.H****

#ifndef STACK_MAIN_H #define STACK_MAIN_H

#include /* cout, endl */ #include /* srand, rand, atoi */ #include /* time */ #include \"stack.h\"

using std::cout; using std::endl;

#endif //STACK_MAIN_H

****MAIN.CPP****

#include \"main.h\" int main(int argc, char** argv) {

}

****STACK.H****

#ifndef STACK_STACK_H #define STACK_STACK_H #define SIZE 10 #define DEFAULTSIZE -1

#include class Stack { public: Stack(); ~Stack(); bool push(int); int pop(); bool isEmpty(); int peek(); int newStack; protected: int top; int *intStack; }; #endif // STACK_STACK_H

****STACK.CPP****

#include \"stack.h\"

Stack::Stack() { int top = DEFAULTSIZE; intStack = new int[SIZE]; }

Stack::~Stack() { delete[] intStack; }

bool Stack::push(int z) { bool set = false; if(top { intStack[++top] = z; set = true; } return set; }

int Stack::pop() { if(top != DEFAULTSIZE && top { int newStack = intStack[--top]; return newStack; } else { throw; } }

bool Stack::isEmpty() { bool set = false; if(top == -1) { set = true; } return set; }

int Stack::peek() { if(top != DEFAULTSIZE && top { int newStack = intStack[top]; } return newStack; }

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions