示例#1
0
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop
            OnlineShop shop = new OnlineShop();
            // 10) declare several objects of Customer
            Customer cSergey  = new Customer("Sergey");
            Customer cAndrey  = new Customer("Andrey");
            Customer cVitaliy = new Customer("Vitaliy");
            Customer cAnna    = new Customer("Anna");
            Customer cOlga    = new Customer("Olga");

            // 11) subscribe method GotNewGoods() of every Customer instance
            // to event NewGoodsInfo of object of OnlineShop
            shop.NewGoodsInfo += cSergey.GotNewGoods;
            shop.NewGoodsInfo += cAndrey.GotNewGoods;
            shop.NewGoodsInfo += cVitaliy.GotNewGoods;
            shop.NewGoodsInfo += cAnna.GotNewGoods;
            shop.NewGoodsInfo += cOlga.GotNewGoods;

            // 12) invoke method NewGoods() of object of OnlineShop
            // discuss results

            shop.NewGoods("Tom Soyer");
            Console.ReadKey();
        }
示例#2
0
 static void Main(string[] args)
 {
     // 9) declare object of OnlineShop 
     OnlineShop shop = new OnlineShop();
     // 10) declare several objects of Customer
     Customer first = new Customer("Chocolate");
     Customer second = new Customer("Milk");
     // 11) subscribe method GotNewGoods() of every Customer instance 
     // to event NewGoodsInfo of object of OnlineShop
     shop.someEvent += new EventHandler<GoodsInfoEventArgs>(first.GotNewGoods);
     shop.someEvent += new EventHandler<GoodsInfoEventArgs>(second.GotNewGoods);
     // 12) invoke method NewGoods() of object of OnlineShop
     // discuss results
     shop.NewGoods();
     Console.ReadKey();
 }
示例#3
0
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop
            OnlineShop shop = new OnlineShop();
            // 10) declare several objects of Customer
            Customer first  = new Customer("Chocolate");
            Customer second = new Customer("Milk");

            // 11) subscribe method GotNewGoods() of every Customer instance
            // to event NewGoodsInfo of object of OnlineShop
            shop.someEvent += new EventHandler <GoodsInfoEventArgs>(first.GotNewGoods);
            shop.someEvent += new EventHandler <GoodsInfoEventArgs>(second.GotNewGoods);
            // 12) invoke method NewGoods() of object of OnlineShop
            // discuss results
            shop.NewGoods();
            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop
            var our_shop = new OnlineShop();
            // 10) declare several objects of Customer
            var customer1 = new Customer("petr");
            var customer2 = new Customer("vasil");

            // 11) subscribe method GotNewGoods() of every Customer instance
            // to event NewGoodsInfo of object of OnlineShop
            our_shop.event4 += customer1.GotNewGoods;
            our_shop.event4 += customer2.GotNewGoods;
            // 12) invoke method NewGoods() of object of OnlineShop
            // discuss results
            our_shop.NewGoods("milk");
            Console.ReadKey();
        }
示例#5
0
文件: Program.cs 项目: Alvek/Braincad
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop 
            OnlineShop shop = new OnlineShop();

            // 10) declare several objects of Customer
            Customer c1 = new Customer("1");
            Customer c2 = new Customer("2");

            // 11) subscribe method GotNewGoods() of every Customer instance 
            // to event NewGoodsInfo of object of OnlineShop
            shop.ev += c1.GotNewGoods;
            shop.ev += c2.GotNewGoods;

            // 12) invoke method NewGoods() of object of OnlineShop
            shop.NewGoods("test");
            // discuss results
            Console.ReadKey();
        }
示例#6
0
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop
            OnlineShop oshop = new OnlineShop();

            // 10) declare several objects of Customer
            Customer cust1 = new Customer("Vasiliy");
            Customer cust2 = new Customer("Yasha");

            // 11) subscribe method GotNewGoods() of every Customer instance
            // to event NewGoodsInfo of object of OnlineShop
            oshop.evGodGoods += cust1.GotNewGoods;
            oshop.evGodGoods += cust2.GotNewGoods;
            oshop.evGodGoods += cust2.GotNewGoods;

            // 12) invoke method NewGoods() of object of OnlineShop
            // discuss results
            oshop.NewGoods("hot pizza!!");
            Console.ReadLine();
        }
示例#7
0
        static void Main(string[] args)
        {
            // 9) declare object of OnlineShop
            OnlineShop shop = new OnlineShop();

            // 10) declare several objects of Customer
            Customer customer1 = new Customer("Jack");
            Customer customer2 = new Customer("John");
            Customer customer3 = new Customer("Jimm");


            // 11) subscribe method GotNewGoods() of every Customer instance
            // to event NewGoodsInfo of object of OnlineShop
            shop.someEvent += customer1.GotNewGoods;
            shop.someEvent += customer2.GotNewGoods;
            shop.someEvent += customer3.GotNewGoods;

            // 12) invoke method NewGoods() of object of OnlineShop
            shop.NewGoods("Malina");
            // discuss results
        }