Пример #1
0
        public void TestEmpty()
        {
            var bottle = new Bottle(12);

            bottle.Fill(7);
            bottle.Empty();
            Assert.AreEqual(0, bottle.Content);
        }
Пример #2
0
 private static void DoOperations(int[] operations, Bottle bottle1, Bottle bottle2, List <int> storage)
 {
     bottle1.Empty();
     bottle2.Empty();
     foreach (var operation in operations)
     {
         if (operation == 0)
         {
             bottle1.FillToTopFromTap();
         }
         else if (operation == 1)
         {
             bottle2.FillToTopFromTap();
         }
         else if (operation == 2)
         {
             bottle2.Fill(bottle1.Empty());
         }
         else if (operation == 3)
         {
             bottle1.Fill(bottle2.Empty());
         }
         else if (operation == 4)
         {
             bottle2.FillToTop(bottle1);
         }
         else if (operation == 5)
         {
             bottle1.FillToTop(bottle2);
         }
         else if (operation == 6)
         {
             bottle1.Empty();
         }
         else if (operation == 7)
         {
             bottle2.Empty();
         }
         //if (storage.Count > 300) storage = new List<int>();
         storage.Add(bottle1.Content);
         storage.Add(bottle2.Content);
     }
 }
Пример #3
0
        public void TestBottleFillOther()
        {
            var bottle  = new Bottle(10);
            var bottle2 = new Bottle(5);

            bottle2.FillFromTap();
            bottle.Fill(bottle2.Empty());

            Assert.AreEqual(5, bottle.Content);
            Assert.AreEqual(0, bottle2.Content);
        }
Пример #4
0
        public void TestBottleEmpty()
        {
            var bottle = new Bottle(10);

            bottle.FillFromTap();

            Assert.AreEqual(10, bottle.Content);

            var oldContent = bottle.Empty();

            Assert.AreEqual(10, oldContent);
            Assert.AreEqual(0, bottle.Content);
        }
Пример #5
0
        public void AddToVolumeFromThisBottle(Bottle targetBottle)
        {
            int amountToAdd = targetBottle.CurrentVolume;

            //If the bottle we're pouring from contains more than we can hold, only take what we can handle.
            if (this.RemainingVolume() < amountToAdd)
            {
                amountToAdd = this.RemainingVolume();
                targetBottle.RemoveVolume(amountToAdd);
            }
            else
            {
                targetBottle.Empty();
            }

            this.CurrentVolume += amountToAdd;
        }