TowerOfHanoi
Public Member Functions | List of all members
Hanoi Class Reference

Hanoi is a class that takes the action of moving disks between rods. It does this by encapsulates Rods for start, destination, and auxilary. More...

#include <hanoi.h>

Collaboration diagram for Hanoi:
Collaboration graph

Public Member Functions

 Hanoi (int disks, bool printState)
 Initializes a Hanoi class with the size of the problem and whether we want to know state. More...
 
void execute (std::ostream &out=std::cout)
 A function that executes the number of disk moves and reports the move set. More...
 

Detailed Description

Hanoi is a class that takes the action of moving disks between rods. It does this by encapsulates Rods for start, destination, and auxilary.

Constructor & Destructor Documentation

◆ Hanoi()

Hanoi::Hanoi ( int  disks,
bool  printState 
)

Initializes a Hanoi class with the size of the problem and whether we want to know state.

This constructor will also initalize the disks on the start rod and swap aux and dest rods on even # of disks.

Parameters
[in]disks- the number of disks that we want to solve the puzzle for.
[in]printState- Determine if we want to print the state per move set.

Member Function Documentation

◆ execute()

void Hanoi::execute ( std::ostream &  out = std::cout)

A function that executes the number of disk moves and reports the move set.

The Tower of Hanoi puzzle has a formulaic set of movement rules for fixed number of moves at 2^n -1. The solution is knowing which move to do. wich is determined by taking the modulo of the number of rods (3).

Parameters
[in]outThe out stream

The documentation for this class was generated from the following files: