Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the following assignment using C++ Task 1: Create a stack class that will be used as the basis for the remainder of the lab
Complete the following assignment using C++
Task 1: Create a stack class that will be used as the basis for the remainder of the lab I. 2. Create a new project Design a stack class using an array. This class should be a template The constructor should include a parameter to indicate the size of the arrav The array holding the data should be an array of pointers The push function should accept a pointer and add that pointer to the top of the stack, It doesn't need to create any memory The pop function should return a pointer. It doesn't need to delete any memory The top function should return a pointer to the item on the top of the stack without removing it The length function will return an int indicating the number of items in the stack. The empty function should empty the stack of all contents. It needs to call delete to avoid memory leaks. It doesn't need to return any value The stack should declare a friend function that can access the underlying array for the purposes of printing it to the screen. Create the implementation code for the above functions as required. Do not use cout in the class. Any errors such as overflow or underflow should throw a custom class error a. b. c. d. e. f. g. h. i. Complete this before moving on to task 2. Task 2: Create a single person version of the "Towers of Hanoi" game 1 Read the introduction to the game at https://en.wikipedia.org/wiki/Tower ofHanoi 2. Create a main program that uses stacks to allows the user to interactively play the game. a. It needs to determine the number of disks to use in the game b. It needs to provide a way for the user to indicate the tower to move from and to It needs to prevent illegal moves as defined in the Wikipedia rules c. d. It needs to provide the user with a way to see their progress on the screen 3. Test your program to ensure it is working correctly. This should test both expected success conditions and expected error conditions Include in the lab report screen shot(s) of the output of all your test cases. 4. Task 1: Create a stack class that will be used as the basis for the remainder of the lab I. 2. Create a new project Design a stack class using an array. This class should be a template The constructor should include a parameter to indicate the size of the arrav The array holding the data should be an array of pointers The push function should accept a pointer and add that pointer to the top of the stack, It doesn't need to create any memory The pop function should return a pointer. It doesn't need to delete any memory The top function should return a pointer to the item on the top of the stack without removing it The length function will return an int indicating the number of items in the stack. The empty function should empty the stack of all contents. It needs to call delete to avoid memory leaks. It doesn't need to return any value The stack should declare a friend function that can access the underlying array for the purposes of printing it to the screen. Create the implementation code for the above functions as required. Do not use cout in the class. Any errors such as overflow or underflow should throw a custom class error a. b. c. d. e. f. g. h. i. Complete this before moving on to task 2. Task 2: Create a single person version of the "Towers of Hanoi" game 1 Read the introduction to the game at https://en.wikipedia.org/wiki/Tower ofHanoi 2. Create a main program that uses stacks to allows the user to interactively play the game. a. It needs to determine the number of disks to use in the game b. It needs to provide a way for the user to indicate the tower to move from and to It needs to prevent illegal moves as defined in the Wikipedia rules c. d. It needs to provide the user with a way to see their progress on the screen 3. Test your program to ensure it is working correctly. This should test both expected success conditions and expected error conditions Include in the lab report screen shot(s) of the output of all your test cases. 4Step 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