using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Proxy
{
/// <summary>
/// 被追求者类
/// </summary>
class
SchoolGirl
{
private
string
name;
public
string
Name
{
get
{
return
name; }
set
{ name = value; }
}
}
/// <summary>
/// 送礼物接口
/// </summary>
interface
IGiveGift
{
void
GiveDolls();
void
GiveFlowers();
void
GiveChocolate();
}
/// <summary>
/// 追求者类
/// </summary>
class
Pursuit : IGiveGift
{
SchoolGirl mm;
public
Pursuit(SchoolGirl mm)
{
this
.mm = mm;
}
public
void
GiveDolls()
{
Console.WriteLine(mm.Name +
",送你洋娃娃!"
);
}
public
void
GiveFlowers()
{
Console.WriteLine(mm.Name +
",送你鲜花!"
);
}
public
void
GiveChocolate()
{
Console.WriteLine(mm.Name +
",送你巧克力!"
);
}
}
/// <summary>
/// 代理类
/// </summary>
class
Proxy : IGiveGift
{
Pursuit gg;
public
Proxy(SchoolGirl mm)
{
gg =
new
Pursuit(mm);
}
public
void
GiveDolls()
{
gg.GiveDolls();
}
public
void
GiveFlowers()
{
gg.GiveFlowers();
}
public
void
GiveChocolate()
{
gg.GiveChocolate();
}
}
class
Program
{
static
void
Main(
string
[] args)
{
SchoolGirl yatou =
new
SchoolGirl();
yatou.Name =
"丫头"
;
Proxy zhutou =
new
Proxy(yatou);
zhutou.GiveChocolate();
zhutou.GiveDolls();
zhutou.GiveFlowers();
Console.Read();
}
}
}