代理模式之泡MM

using System; using System.Collections.Generic; using System.Text; namespace Proxy { /// <summary> /// 泡MM是需要给MM送花,送巧克力的 /// /// </summary> interface IGiveGift { void GiveFlowers(); void GiveChocolate(); } /// <summary> /// 追求 MM /// </summary> class Pursuit : IGiveGift { //所追求的MM Girl GF; public Pursuit(Girl MM) { GF = MM; } /// <summary> /// 送花,送巧克力给MM /// </summary> public void GiveFlowers() { Console.WriteLine("送花给{0}MM,该MM的特点:{1}", GF.Name, GF.Feature); } public void GiveChocolate() { Console.WriteLine("送巧克力给{0}MM,该MM的特点:{1}", GF.Name, GF.Feature); } } /// <summary> /// 代理类 /// </summary> class Proxyer { //我喜欢的MM是 public Proxyer(Girl MM) //谁代理我去追我喜欢的MM,那就是Pursuit Pursuit GG; public Proxyer(Girl MM) { GG = new Pursuit(MM); } /// <summary> /// 代理我去追MM的人,要送花,巧克力给MM /// </summary> public void GiveFlowers() { GG.GiveFlowers(); } public void GiveChocolate() { GG.GiveChocolate(); } } /// <summary> /// 定义追求MM的类 /// </summary> class Girl { private string name; private string feature="可爱,漂亮"; public string Name { set { name = value; } get { return name; } } public string Feature { get { return feature; } } } class Class1 { static void Main() { //要追求的MM叫娜娜 Girl GF = new Girl(); GF.Name = "娜娜"; Proxyer Guo = new Proxyer(GF); Guo.GiveFlowers(); Guo.GiveChocolate(); } } }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值