Beispiel #1
0
 public void ArrangeFood(object sender, EatEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine("仆人说:");
     Console.WriteLine("我的主人, 您的命令是 : ");
     Console.WriteLine("吃饭地点 -- {0}", e.restrauntName);
     Console.WriteLine("准备消费 -- {0}元 ", e.moneyOut);
     Console.WriteLine("好的,正给您安排。。。。。。。。\n");
     System.Threading.Thread.Sleep(5000);
     Console.WriteLine("主人,您的食物在这儿,请慢用");
     Console.Read();
 }
Beispiel #2
0
        //当主人饿的时候,他会指定吃饭地点和消费金额。
        public void Hungry(String restrauntName, decimal moneyOut)
        {
            EatEventArgs e = new EatEventArgs();

            e.restrauntName = restrauntName;
            e.moneyOut      = moneyOut;

            Console.WriteLine("主人说:");
            Console.WriteLine("我饿了,要去{0}吃饭,消费{1}元", e.restrauntName, e.moneyOut);

            //引发事件
            OnEatEvent(e);
        }
Beispiel #3
0
 //引发事件的方法
 public void OnEatEvent(EatEventArgs e)
 {
     EatEvent?.Invoke(this, e);
 }