private string MoveDisk(Move move) { var sourceTower = _diskFinder.FindDisk(this, move.Disk); var destinationTower = _towerFinder.Find(this, sourceTower, move.StepDirection); sourceTower.RemoveDisk(); destinationTower.AddDisk(move.Disk); return string.Format("Move Disk {0} from {1} to {2}", move.Disk, sourceTower, destinationTower); }
public Move GenerateNextMove(Game game, int diskCount, string disk) { var index = new AlphaNumericConverter().AlphaToNumeric(disk); var move = new Move { Disk = disk }; var oddStackPositionStepDirection = StackHasOddNumberOfDisks(diskCount) // If stack has an odd disk count ? StepDirection.Left // start with move to left : StepDirection.Right; // else start with move to the right // Disks moves alternate between left and right move.StepDirection = DiskIsInEvenStackPosition(index) ? ReverseStepDirection(oddStackPositionStepDirection) : oddStackPositionStepDirection; return move; }