Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with witch case to help user navigate tower of hanoi puzzle class Stack { public: Stack ( ) ; ~Stack ( ) ; bool
Help with witch case to help user navigate tower of hanoi puzzle class Stack
public:
Stack;
~Stack;
bool isEmpty;
bool isFull;
void pushint val;
int pop;
int count;
int peekint pos;
void changeint pos, int val;
void display;
private:
int top;
int arr;
; #include
#include "mainh
using namespace std;
Stack::Stack
top ;
for int i ; i ; i
arri;
Stack::~Stack
bool Stack::isEmpty
iftop
cout is empty" endl;
return true;
else
cout is not empty." endl;
return false;
bool Stack::isFull
iftop
cout is full." endl;
return true;
else
cout is not full." endl;
return false;
void Stack::pushint val
if isFull
cout "Overflow" endl;
else
top;
arrtop val;
int Stack::pop
if isEmpty
cout "Stack underflow" endl;
return ;
else
int popValue arrtop;
arrtop;
top;
return popValue;
int Stack::count
return top ;
int Stack::peekint pos
if isEmpty
cout "Stack underflow" endl;
return ;
else
return arrpos;
void Stack::changeint pos, int val
arrpos val;
cout "Value changed at position pos endl;
void Stack::display
cout "All items in stack are:" endl;
for int i top; i ; i
cout arri endl;
void towerOfHanoiint disks, Stack &source, Stack &auxiliary, Stack &destination
if disks
int disk source.pop;
destination.pushdisk;
cout "Move disk disk from Tower &source to Tower &destination endl;
return;
towerOfHanoidisks source, destination, auxiliary;
int disk source.pop;
destination.pushdisk;
cout "Move disk disk from Tower &source to Tower &destination endl;
towerOfHanoidisks auxiliary, source, destination;
int main
int numDisks ; Change the number of disks here
Stack towerA, towerB, towerC;
char answer;
int option, choice;
cout "Would you like to see stack options? Y or N ;
cin answer;
ifanswer Y answer y
do
cout "What operation do you want to perform? Select Option number. Enter to exit." endl; HELP WITH OPTION PROMPTING USER TO TAKE STEPS TO MOVE RINGS AND SOLVE PUZZLE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started