Beispiel #1
0
 public  void store_OnNewBook(BookStore store, Domain dom, string book)
  {
      if (dom == _dom)
      {
          Console.WriteLine("{0}知道{1}书店新到《{2}》", _name, store.Name, book);
          Console.WriteLine();
      }
  }
Beispiel #2
0
            static void Main(string[] args)
            {
                BookStore store1 = new BookStore("中关村");
                BookStore store2 = new BookStore("中山路");
                Customer[] cs = new Customer[] {
                                  new Customer("王晓明", Domain.Computer),
                                  new Customer("赵丽", Domain.Computer), 
                                         new Customer("张珊", Domain.Literature) 
                                };
                foreach (Customer c in cs)
                {
                    c.Register(store1);
                    c.Register(store2);
                }
                store1.NewBook(Domain.Computer, "C#程序设计");
                store2.NewBook(Domain.Literature, "唐诗三百首");
                Console.WriteLine("**************************************");
                cs[0].Unregister(store2);
                store2.NewBook(Domain.Computer, "数据结构与算法");

                Console.ReadKey();
            }
Beispiel #3
0
 //取消客户注册
 public void Unregister(BookStore store)      
 {
     //待写
 }
Beispiel #4
0
 //客户注册
 public void Register(BookStore store)
 {
     List<Customer> cl = store.GetCustomerList();
     cl.Add(this);
 } 
Beispiel #5
0
 //客户注册
 public void Register(BookStore store)
 {
     /*
     List<Customer> cl = store.GetCustomerList();
     cl.Add(this);
      * */
     store.OnNewBook += this.store_OnNewBook;
 }
Beispiel #6
0
 //取消客户注册
 public void Unregister(BookStore store)
 {
     //待写
     store.OnNewBook -= this.store_OnNewBook;
 }