Exemplo n.º 1
0
        public void ExceptionTest()
        {
            var       salad   = new Salad();
            Vegetable cabbage = new Cabbage(100, 24, "1 year");

            salad.Add(cabbage);

            Assert.Throws(typeof(Exception), () => salad.Add(cabbage));
        }
Exemplo n.º 2
0
        public void SaladCollectionCreationTest()
        {
            Salad salad = new Salad();

            salad.Add(new Cabbage(100, 24, "1 year"));
            salad.Add(new Cucumber(50, 15, "1 year"));
            salad.Add(new SweetPepper(100, 50, "1 year"));
            salad.Add(new Tomato(150, 25, "1 year"));
            salad.Add(new Potato(200, 45, "Greenhouse type"));
            Assert.IsNotEmpty(salad.SaladCollection);
            Console.WriteLine("Collection contains some objects and hence is not empty.");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Initialize the repository
            Restaurant restaurant = new Restaurant("Casa Domingo");

            // Initialize the entities
            Vegetable tomato   = new Vegetable("Tomato", 20);
            Vegetable cucumber = new Vegetable("Cucumber", 15);

            Salad salad = new Salad("Tomatoes with cucumbers");

            salad.Add(tomato);
            salad.Add(cucumber);

            Console.WriteLine(salad.GetTotalCalories()); // 35
            Console.WriteLine(salad.GetProductCount());  // 2

            Console.WriteLine(salad.ToString());
            // * Salad Tomatoes with cucumbers is 35 calories and have 2 products:
            //  - Tomato have 20 calories
            //  - Cucumber have 15 calories

            restaurant.Add(salad);

            Console.WriteLine(restaurant.Buy("Invalid salad")); // False

            // Initialize the second entities
            Vegetable corn        = new Vegetable("Corn", 90);
            Salad     casaDomingo = new Salad("Casa Domingo");

            casaDomingo.Add(tomato);
            casaDomingo.Add(cucumber);
            casaDomingo.Add(corn);

            restaurant.Add(casaDomingo);

            Console.WriteLine(restaurant.GetHealthiestSalad()); // Tomatoes with cucumbers

            Console.WriteLine(restaurant.GenerateMenu());
            // Casa Domingo have 2 salads:
            // * Salad Tomatoes with cucumbers is 35 calories and have 2 products:
            //  - Tomato have 20 calories
            //  - Cucumber have 15 calories
            // * Salad Casa Domingo is 125 calories and have 3 products:
            //  - Tomato have 20 calories
            //  - Cucumber have 15 calories
            //  - Corn have 90 calories
        }
Exemplo n.º 4
0
        public void CollectionContainsAnObjectTest()
        {
            Salad     salad  = new Salad();
            Vegetable potato = new Potato(200, 45, "Greenhouse type");

            salad.Add(potato);
            Assert.Contains(potato, salad.SaladCollection);
            Console.WriteLine("Collection contains Potato object.");
        }
Exemplo n.º 5
0
    private IEnumerator ChopVegtableRoutine()
    {
        _canMove = false;
        yield return(new WaitForSeconds(m_ChopSpeed));

        Vegetable vegetable = m_Vegetables.First();

        _salad.Add(vegetable);
        m_Vegetables.Remove(vegetable);
        UIManager.Instance.UpdateChoppingBoardStatus(_salad.ToString(), m_IsPlayer1);
        _canMove = true;
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Calories cl = new Calories(2, 3, 4);
            Calories c2 = 2*cl;

            var potato = new  Potato(100);
            var cucmber = new Cucumber(100);
            var carrot = new Carrot(200);

            var cust = new CustomVegetable("1", 2, new Calories());
            Console.WriteLine(cust);
            cust.Weight = 3;
            cust.Calories = new Calories();
            cust.Name = "13";
            Console.WriteLine(cust);

            Console.WriteLine(potato.Name + " " + potato.Calories + " " + potato.Weight);
            Console.WriteLine(cucmber.Name + " " + cucmber.Calories + " " + cucmber.Weight);
            Console.WriteLine(carrot.Name + " " + carrot.Calories + " " + carrot.Weight);
            List<IVegetable> lst = new List<IVegetable>();
            lst.Add(cucmber);

            Salad salad = new Salad(new CloneList<IVegetable>());
            salad.Add(potato);
            salad.Add(carrot);
            salad.Add(cucmber);
            Console.WriteLine("total calories = " + salad.TotalCalories);
            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();
            var tt = salad.GetVegetables(0, 1000);

            Console.WriteLine();
            Console.WriteLine();
            salad.PrintVegetables();

            salad.Sort(VegetableComparasions.CompareByName);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("BEFORE SRT");
            salad.PrintVegetables();

            salad.Sort(vegetable => vegetable.Calories, new CompareByCalories());

            Func<int, int> d = delegate(int i) { return i*3; };

            Console.WriteLine("AFTER SRT");
            salad.PrintVegetables();
            salad.Sort(VegetableComparasions.CompareByWeight);
            Console.WriteLine("BEFORE REMOVE");
            salad.PrintVegetables();
            salad.Remove(potato);

            Console.WriteLine("AFTER REMOVE");
            salad.PrintVegetables();

            Console.WriteLine("TESTTTT");
            CloneList<IVegetable> list = new CloneList<IVegetable>();

            List<int> li = new List<int>();

            list.Add(potato);
            list.Add(cucmber);
            list.Add(carrot);
            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");

            ICloneCollection<IVegetable> list2 = list.CloneObjects();
            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            list[0].Weight = 0;
            list[1].Weight = 0;
            list[2].Weight = 0;

            Console.WriteLine("TESTTTT");

            foreach (var v in list)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
            Console.WriteLine("CLONE");

            foreach (var v in list2)
            {
                Console.WriteLine(v.Name + " " + v.Calories + " " + v.Weight);
            }
        }