public void Add_SmallerSecondDisk_AddsOneMoreDiskToTower() { var tower = new Tower(); tower.AddDisk("B"); tower.AddDisk("A"); tower.Count.ShouldEqual(2); tower.TopDisk().ShouldEqual("A"); }
public void Add_LargerSecondDisk_ThrowsException() { var tower = new Tower(); tower.AddDisk("A"); try { tower.AddDisk("B"); } catch (InvalidOperationException ex) { } tower.Count.ShouldEqual(1); tower.TopDisk().ShouldEqual("A"); }
public void Add_FirstDisk_AddsOneDiskToTower() { var tower = new Tower(); tower.AddDisk("A"); tower.Count.ShouldEqual(1); tower.TopDisk().ShouldEqual("A"); }
public IEnumerator MoveDisk(Tower targetTower) { yield return(stack.Peek().MoveDisk(targetTower)); if (stack.Count > 0) { targetTower.AddDisk(RemoveDisk()); } }
private async Task SolveTower(int totalDisks, Tower start, Tower end, Tower mid) { if (totalDisks > 0) { await SolveTower(totalDisks - 1, start, mid, end); ++_moveStep; var disk = start.RemoveDisk(); end.AddDisk(disk); var mov = new Move(new List <Tower> { start, end, mid }, disk, _moveStep, _hanoi); _moveRepository.NoTransactionAdd(mov); await SolveTower(totalDisks - 1, mid, end, start); } }
private void CreateStartedDisk() { for (int i = 0; i < listDisks.Count; i++) { Destroy(listDisks[i].gameObject); } listDisks.Clear();; for (int i = 0; i < diskCount; i++) { Disk disk = Instantiate(DiskPrefab); disk.Initialization(i, StartTower); StartTower.AddDisk(disk); listDisks.Add(disk); } }