Exemplo n.º 1
0
 public void CrossMonkeys()
 {
     if (RightCount > 0 && LeftCount == 0 && MonkeysOnRope == 0)
     {
         ShowArrow();
         ShowMonkey();
         MonkeysOnRope++;
         Assert.AreEqual(1, MonkeysOnRope);
         RightCount = (RightCount - 1);
         Assert.AreEqual(RightCount - 1, RightCount);
     }
     else if (LeftCount > 0 && RightCount == 0 && MonkeysOnRope == 0)
     {
         ShowArrow();
         ShowMonkey();
         MonkeysOnRope++;
         Assert.AreEqual(1, MonkeysOnRope);
         LeftCount = (LeftCount - 1);
         Assert.AreEqual(LeftCount - 1, LeftCount);
     }
     else if (RightArrow.Equals(true) && MonkeysOnRope == 0)
     {
         ShowMonkey();
         MonkeysOnRope++;
         Assert.AreEqual(1, MonkeysOnRope);
         LeftCount = (LeftCount - 1);
         Assert.AreEqual(LeftCount - 1, LeftCount);
     }
     else if (LeftArrow.Equals(true) && MonkeysOnRope == 0)
     {
         ShowMonkey();
         MonkeysOnRope++;
         Assert.AreEqual(1, MonkeysOnRope);
         RightCount = (RightCount - 1);
         Assert.AreEqual(RightCount - 1, RightCount);
     }
     else if (MonkeysOnRope > 0)
     {
         MoveMonkeyForward();
     }
 }
Exemplo n.º 2
0
 public void MoveMonkeyForward()
 {
     if (MonkeysOnRope < 3 && !FinishCrossing)
     {
         if (LeftArrow.Equals(true) && RightCount > 0)
         {
             if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(1, MonkeysOnRope);
                 RightCount = (RightCount - 1);
                 Assert.AreEqual(RightCount - 1, RightCount);
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(2, MonkeysOnRope);
                 RightCount = (RightCount - 1);
                 Assert.AreEqual(RightCount - 1, RightCount);
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(3, MonkeysOnRope);
                 RightCount = (RightCount - 1);
                 Assert.AreEqual(RightCount - 1, RightCount);
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(3, MonkeysOnRope);
                 RightCount = (RightCount - 1);
                 Assert.AreEqual(RightCount - 1, RightCount);
             }
         }
         else if (LeftArrow.Equals(true) && RightCount == 0)
         {
             if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(false))//One monkey
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(true))
             {
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(0, MonkeysOnRope);
                 HideMonkey();
                 HideArrow();
                 ShowArrow();
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(1, MonkeysOnRope);
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(2, MonkeysOnRope);
                 HideMonkey();
             }
         }
         if (RightArrow.Equals(true) && LeftCount > 0)
         {
             if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(1, MonkeysOnRope);
                 LeftCount = (LeftCount - 1);
                 Assert.AreEqual(LeftCount - 1, LeftCount);
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(true))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(2, MonkeysOnRope);
                 LeftCount = (LeftCount - 1);
                 Assert.AreEqual(LeftCount - 1, LeftCount);
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(3, MonkeysOnRope);
                 LeftCount = (LeftCount - 1);
                 Assert.AreEqual(LeftCount - 1, LeftCount);
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 MonkeysOnRope++;
                 Assert.AreEqual(3, MonkeysOnRope);
                 LeftCount = (LeftCount - 1);
                 Assert.AreEqual(LeftCount - 1, LeftCount);
             }
         }
         else if (RightArrow.Equals(true) && LeftCount == 0)
         {
             if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(true))
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(false))
             {
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(0, MonkeysOnRope);
                 HideMonkey();
                 HideArrow();
                 ShowArrow();
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 ShowMonkey();
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(false))
             {
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(1, MonkeysOnRope);
                 HideMonkey();
             }
             else if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 HideMonkey();
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
                 MonkeysOnRope--;
                 Assert.AreEqual(2, MonkeysOnRope);
             }
         }
     }
     else if (MonkeysOnRope == 3 || FinishCrossing)
     {
         if (LeftArrow.Equals(true))
         {
             if (LeftCount > 0)
             {
                 FinishCrossing = true;
             }
             if (RopeRightMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(2, MonkeysOnRope);
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeLeftMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(1, MonkeysOnRope);
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
             }
             else if (RopeRightMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeLeftMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(0, MonkeysOnRope);
                 LeftCount = (LeftCount + 1);
                 Assert.AreEqual(LeftCount + 1, LeftCount);
                 HideArrow();
                 ShowArrow();
                 FinishCrossing = false;
             }
         }
         else if (RightArrow.Equals(true))
         {
             if (RightCount > 0)
             {
                 FinishCrossing = true;
                 Assert.AreEqual(true, FinishCrossing);
             }
             if (RopeLeftMonkey.Equals(true) && RopeCenterMonkey.Equals(true) && RopeRightMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(2, MonkeysOnRope);
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
             }
             else if (RopeLeftMonkey.Equals(false) && RopeCenterMonkey.Equals(true) && RopeRightMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(1, MonkeysOnRope);
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
             }
             else if (RopeLeftMonkey.Equals(false) && RopeCenterMonkey.Equals(false) && RopeRightMonkey.Equals(true))
             {
                 HideMonkey();
                 MonkeysOnRope--;
                 Assert.AreEqual(0, MonkeysOnRope);
                 RightCount = (RightCount + 1);
                 Assert.AreEqual(RightCount + 1, RightCount);
                 HideArrow();
                 ShowArrow();
                 FinishCrossing = false;
                 Assert.AreEqual(false, FinishCrossing);
             }
         }
     }
 }