CS 105 (C++)

Assignment 6: The Tower of Hanoi


I. Overview


In this assignment, you will complete the implementation of a text-based Tower of Hanoi game by creating a dynamically allocated stack class.  (As in Assignment 4, the stack's internal storage will be implemented as a linked list, with the head of the list corresponding to the top of the stack.)

You will use a6_main.cpp (download here) that handles game logic and display, and you will implement your class Stack within the files Stack.h and Stack.cpp.  The given a6_main.cpp should not be modified; doing so may cause your code to work incorrectly during grading.

Your implementation must meet the following requirements:
If your Stack class is properly implemented, you will be able to compile it with the given a6_main.cpp to produce a working simulation of the Tower of Hanoi game.  There's a detailed description at the Wikipedia link above, but basically, your goal is to transfer the tower from the first peg to the last by moving one disc at a time, with the restriction that you can never place a larger disc on top of a smaller one.  Be sure to test your completed implementation thoroughly.

You can compile the entire program by listing the .cpp files as arguments to g++ as follows:

g++ a6_main.cpp Stack.cpp -o a6


II. Grading


The following is a list of specific assignment requirements, along with the grade value for each (out of a total of 10 points for the assignment).



Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.