public HanoiInstructions(int n, string leftPegName, string centerPegName, string rightPegName) { _leftPeg = new Peg(n, leftPegName); _centerPeg = new Peg(n, centerPegName); _rightPeg = new Peg(n, rightPegName); GetInstructions(n, _leftPeg, _centerPeg, _rightPeg); }
public Instruction(int disk, Peg A, Peg B) { Disk = disk; StartPeg = A; EndPeg = B; StartPeg._pegArray[Disk - 1] = false; EndPeg._pegArray[Disk - 1] = true; }
public void GetInstructions(int disk, Peg startPeg, Peg auxPeg, Peg endPeg) { if (disk == 1) { InstructionList.Add(new Instruction(disk, startPeg, endPeg)); } else { GetInstructions(disk - 1, startPeg, endPeg, auxPeg); InstructionList.Add(new Instruction(disk, startPeg, endPeg)); GetInstructions(disk - 1, auxPeg, startPeg, endPeg); } }