コード例 #1
0
        static void Main(string[] args)
        {
            Gift Present1 = new Gift("Gift1", new List <IBasicSweet>());

            var Sweet1 = new CandyAlenka();
            var Sweet2 = new CandyFondant();
            var Sweet3 = new CandyFondant();
            var Sweet4 = new CandyTruffle();
            var Sweet5 = new CookiesBiscuit();
            var Sweet6 = new CookiesGingerbreadMan();

            Present1.AddSweet(Sweet1);
            Present1.AddSweet(Sweet2);
            Present1.AddSweet(Sweet3);
            Present1.AddSweet(Sweet4);
            Present1.AddSweet(Sweet5);
            Present1.AddSweet(Sweet6);
            Present1.DeletedSweet(Sweet2);
            Present1.AddSweet(Sweet2);

            Present1.ShowAll();
            Present1.SortByWeight();
            Present1.SortByName();
            var resultWeightSum = Present1.WeigtSum.ToString();

            Present1.CopmareBySugar(20);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Senkel/EpamTask1
        static void Main(string[] args)
        {
            Sweet              sweet        = new Sweet("Alenka", 450, 51, 520, 0.45);
            SweetWithFilling   sweetwf      = new SweetWithFilling("Grilling", 500, 56, 540, 0.5, "Nut", 0.01);
            Caramel            caramel      = new Caramel("Chupa-Chups", 440, 55, 440, 0.52);
            CaramelWithFilling caramelwf    = new CaramelWithFilling("Korovka", 510, 59, 490, "Milk", 0.05, 0.55);
            ChocolateBar       chocolateBar = new ChocolateBar("Spartak", 550, 66, 550, 0.55);
            Truffle            truffle      = new Truffle("Golden night", 350, 54, 500, 0.5, "Nut", 0.01);


            Gift gift = new Gift("Christmas Gift", new List <ISweet>());

            gift.AddSweet(sweet);
            gift.AddSweet(sweetwf);
            gift.AddSweet(caramel);
            gift.AddSweet(truffle);
            gift.AddSweet(chocolateBar);
            gift.AddSweet(caramelwf);
            gift.RemoveSweet(sweet);
            gift.AddSweet(sweet);


            Console.WriteLine("Gift price is (rubles): {0,13}", gift.GetGiftPrice());
            Console.WriteLine("______________________________________");

            Console.WriteLine("Total weight of gift is (gramm): {0} ", gift.GetWeight());
            Console.WriteLine("______________________________________");

            Console.WriteLine("Sort by weight:");
            foreach (var i in gift.SortByWeight())
            {
                Console.WriteLine("{0,20} \t {1,10}", i.Name, i.Weight);
            }
            Console.WriteLine("______________________________________");
            Console.WriteLine("Find sweet by sugar: ");

            foreach (var i in gift.FindSweetBySugar(52, 57))
            {
                Console.WriteLine("{0,25} \t {1,2}", i.Name, i.Sugar);
            }



            Console.ReadLine();
        }