示例#1
0
        static void Main(string[] args)
        {
            Product printer = new Printer(1, "Техника", 1200, 12);
            Product pC      = new PC(2, "Техника", 1500);
            Product scaner  = new Scaner(3, "Техника", 1100, 7);

            printer.Info();
            pC.Info();
            Client client = new Client("Vlad", 50000);

            client.Put(1200);
            client.Take(5000);
            WriteLine(client.CurrentSum);
            Output output = new Output();

            ((Text)output).print();
            ((Tuxt)output).print();
            BaseClient obj = client as BaseClient;

            obj = client;
            obj.Put(1321);
            WriteLine(obj.CurrentSum);
            IAccount obj2 = client as IAccount;

            obj2.Put(12);
            WriteLine(obj2.CurrentSum);
            WriteLine(pC.ToString());
            Printers printers = new Printers();
            var      mass     = new[] { pC, printer, scaner };

            for (int i = 0; i < 3; i++)
            {
                printers.IAmPrinting(mass[i]);
            }

            ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            Equipment printer  = new Printer(1, 2, "Принтер", 1200, 12);
            Equipment pC       = new PC(2, 4, "Компьютер", 1500);
            Equipment scaner   = new Scaner(3, 1, 1700, "Сканер", 7);
            Printer   printer1 = new Printer(4, 6, "Техника", 1762, 5);

            printer.Info();
            pC.Info();
            Client client = new Client("Vlad", 50000);

            client.Put(1200);
            client.Take(5000);
            WriteLine(client.CurrentSum);
            Output output = new Output();

            ((Text)output).print();
            ((Tuxt)output).print();
            BaseClient obj = client as BaseClient;

            obj = client;
            obj.Put(1321);
            WriteLine(obj.CurrentSum);
            IAccount obj2 = client as IAccount;

            obj2.Put(12);
            WriteLine(obj2.CurrentSum);
            WriteLine(pC.ToString());
            Printers printers = new Printers();
            var      mass     = new[] { pC, printer, scaner };

            for (int i = 0; i < 3; i++)
            {
                printers.IAmPrinting(mass[i]);
            }
            Person person = new Person();

            Write("Имя: ");
            person.name = ReadLine();
            WriteLine();
            Write("Возраст: ");

            person.age = Convert.ToInt32(ReadLine());
            Mounth mounth = Mounth.October;

            WriteLine(mounth + 1);
            printer1.ShowInfo();
            Control laboratory = new Control();

            laboratory.Push(pC);
            laboratory.Push(printer);
            laboratory.Push(scaner);
            laboratory.Show();
            WriteLine();
            laboratory.Count();
            laboratory.Age(3);

            laboratory.Librariary.Sort(laboratory);
            laboratory.Show();
            WriteLine();

            Man man = new Man();

            try
            {
                man.Money = 99;
            }
            catch (ManException ex)
            {
                WriteLine(ex.Message);
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (StrException ex)
            {
                WriteLine(ex.Message);
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (DivideByZeroException ex)
            {
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
                WriteLine("Деление на ноль!");
            }
            catch (OverflowException ex)
            {
                WriteLine("Данное число не входит в диапазон");
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch (MoneyException ex)
            {
                WriteLine(ex.Message + " he has " + ex.Money + "$");
                StackTrace stackTrace = new StackTrace(ex, true);
                WriteLine(stackTrace);
            }
            catch
            {
            }


            Prove();
            ReadKey();
        }