/*	Towers of Hanoi program.
	Demonstrates the solution to a three-ring puzzle */

#include <pegclass.h>
#include "utility.h"

using namespace std;	// October 5, 2001

//--------------------------------------------------------------------------------
void MoveRing(PegClass &FromPeg, PegClass &ToPeg)
/*	Moves a ring from the FromPeg to the ToPeg
	Pre: FromPeg is not empty
	Post: ring has been moved                                 */
{
	int Size = FromPeg.RemoveRing();
	ToPeg.AddRing(Size);
}
//--------------------------------------------------------------------------------
int main()
{
	PegClass Left(7), Middle(7), Right(7);

	const int NumRings = 3;

	// Fill Left ring with NumRings, starting with biggest
	for (int Ring=NumRings; Ring>=1; Ring--)
		Left.AddRing(Ring);

	MoveRing(Left, Middle); Pause(); Left.ShowAll();
	MoveRing(Left, Right); Pause(); Left.ShowAll();
	MoveRing(Middle, Right); Pause(); Left.ShowAll();
	MoveRing(Left, Middle); Pause(); Left.ShowAll();
	MoveRing(Right, Left); Pause(); Left.ShowAll();
	MoveRing(Right, Middle); Pause(); Left.ShowAll();
	MoveRing(Left, Middle); Pause(); Left.ShowAll();

	return(0);
}

