示例#1
0
        public void TestBottleFillToTop()
        {
            var bottle  = new Bottle(10);
            var bottle2 = new Bottle(5);

            bottle2.FillFromTap();
            bottle.FillToTop(bottle2);

            Assert.AreEqual(0, bottle2.Content);
            Assert.AreEqual(5, 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);
     }
 }