Exemple #1
0
        public void sort()
        {
            Товар ex  = new Товар("");
            Товар ex1 = new Товар("");

            for (int i = 0; i < this.Count - 1; i++)
            {
                if (this.ElementAt(i) is Товар)
                {
                    ex  = (Товар)this.ElementAt(i);
                    ex1 = (Товар)this.ElementAt(i + 1);
                    if (ex.weight < ex1.weight)
                    {
                        sorts();
                    }
                }
            }
            void sorts()
            {
                this.Remove(ex);
                this.Remove(ex1);
                this.Add(ex1);
                this.Add(ex);
                sort();
            }
        }
Exemple #2
0
 public void print()
 {
     Console.WriteLine("--------------------------------------------------------------------------------");
     for (int i = 0; i < this.Count; i++)
     {
         if (this.ElementAt(i) is Товар)
         {
             Товар ex = new Товар("");
             ex = (Товар)this.ElementAt(i);
             Console.WriteLine(ex.ToString());
         }
     }
     Console.WriteLine("--------------------------------------------------------------------------------");
 }
Exemple #3
0
        public int Cost()
        {
            int cost = 0;

            for (int i = 0; i < this.Count; i++)
            {
                if (this.ElementAt(i) is Товар)
                {
                    Товар ex = new Товар("");
                    ex    = (Товар)this.ElementAt(i);
                    cost += ex.cost;
                }
            }
            return(cost);
        }
Exemple #4
0
        public void smass()
        {
            int    mass      = Int32.MaxValue;
            bool   mass_test = false;
            string info      = "";

            for (int i = 0; i < this.Count; i++)
            {
                if (this.ElementAt(i) is Товар)
                {
                    Товар ex = new Товар("");
                    ex = (Товар)this.ElementAt(i);
                    if (ex.weight < mass)
                    {
                        mass = ex.weight; mass_test = true; info = ex.ToString();
                    }
                }
            }
            if (mass_test)
            {
                Console.WriteLine("Самая маленькая масса: " + info);
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            try
            {
                Товар qwerty = new Товар("Абвгд", 1900, 30);
                Console.WriteLine(((IInterface)qwerty).Weight());
                Console.WriteLine(((IInterface2)qwerty).Weight());
                Конфеты sweet   = new Конфеты("Комунарка", 540, 3, 2, 75, "Черёмуха", 1);
                Торт    cake    = new Торт("Чараўнiца", 5540, 1, 2, 75, "Наполеон", 10);
                Часы    clocks  = new Часы("Луч", 130, 10, Часы.Types.cvartz, 100);
                Часы    clocks2 = new Часы("GearWatch", 130, 10, Часы.Types.meh, 100);
                Цветы   flowers = new Цветы("Розы", 480, 33, 50, "Красные", 2);
                Console.WriteLine(sweet.ToString());
                Console.WriteLine(cake.ToString());
                Console.WriteLine(clocks.ToString());
                Console.WriteLine(clocks2.ToString());
                Console.WriteLine(flowers.ToString());
                Console.WriteLine(cake is Продукт);
                Console.WriteLine(clocks is int);
                Console.WriteLine(flowers as Товар);
                Printer pr = new Printer();
                Console.WriteLine(pr.iAmPrinting(cake));
                pereopr x = new pereopr();
                Console.WriteLine(x);
                Портфель myBag = new Портфель("Columbia", 35);
                myBag.Info();
                Подарок     p1  = new Подарок(sweet, cake, clocks, flowers);
                PController pc1 = new PController(p1);
                Console.WriteLine("Общая стоимость подарка: $" + pc1.Cost());
                pc1.smass();
                pc1.sort();
                pc1.print();
                //dividenull(7, 0);//ERROR
                //My_Throw(7, -11);
                test.t = true;
                test.assert();
            }

            catch (except1 ex) when(ex.HelpLink == null)
            {
                Console.WriteLine("Не задана вспомогательная ссылка");
            }
            catch (except1 ex) { Console.WriteLine(ex.HelpLink); }
            catch (Exception ex)
            {
                Console.WriteLine("------------------------------------------");
                Console.WriteLine(ex.Message + "\n");
                Console.WriteLine(ex.TargetSite + "\n");
                Console.WriteLine(ex.StackTrace + "\n");
                Console.WriteLine(ex.HelpLink + "\n");
                if (ex.Data != null)
                {
                    Console.WriteLine("Сведения: \n");
                    foreach (DictionaryEntry d in ex.Data)
                    {
                        Console.WriteLine(" {0} {1}", d.Key, d.Value);
                    }
                    Console.WriteLine("------------------------------------------");
                }
            }

            finally { if (!test.t)
                      {
                          Console.WriteLine("Программа завершена с ошибкой");
                      }
            }
        }