프록시 모드 - 코드 버전 "펜던트 이야기"
2846 단어 프록시 모드
namespace ProxyDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//there is a shyboy's dream girl named xuxiao
DreamGirl girl = new DreamGirl();
girl.name = "xuxiao";
//there is a shyboy name kevin kong,he love the girl,but he never said to her that he love her.
ShyBoy shyBoy = new ShyBoy();
shyBoy.name = "Kevin Kong";
//once ,he want through he and the dream gril's commen friend,guimeng,to say he like her.
GoodFriend goodFriend = new GoodFriend(shyBoy, girl);
goodFriend.SendFlower();
goodFriend.SendLoveMail();
goodFriend.SendShortMessage();
//finnally the shyboy never said his love to the girl and he lost her forever.
}
}
}
namespace ProxyDemo
{
/// <summary>
/// this is a pretty girl.
/// </summary>
class DreamGirl
{
public string name { get; set; }
}
}
namespace ProxyDemo
{
/// <summary>
/// this boy want to pursuit the pretty girl but he doesn't dare.
/// </summary>
class ShyBoy:IPursuitMethod
{
public string name;
public void SendLoveMail()
{
MessageBox.Show("Send Love Mail");
}
public void SendFlower()
{
MessageBox.Show("Send Love Flower");
}
public void SendShortMessage()
{
MessageBox.Show("Send Love ShortMessage");
}
}
}
namespace ProxyDemo
{
//GM is they commen friend.
class GoodFriend:IPursuitMethod
{
private ShyBoy shyBoy;
private DreamGirl girl;
public GoodFriend(ShyBoy shyBoy,DreamGirl girl)
{
this.shyBoy = shyBoy;
this.girl = girl;
}
public void SendLoveMail()
{
MessageBox.Show("Send Love Mail to "+girl.name+" for "+shyBoy.name);
}
public void SendFlower()
{
MessageBox.Show("Send Love Flower to " + girl.name + " for " + shyBoy.name);
}
public void SendShortMessage()
{
MessageBox.Show("Send Love Message to " + girl.name + " for " + shyBoy.name);
}
}
}
namespace ProxyDemo
{
/// <summary>
/// guys using those mothed to pursuit the pretty girl.
/// </summary>
interface IPursuitMethod
{
void SendLoveMail();
void SendFlower();
void SendShortMessage();
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간편한 Java 프록시 모드여러분과 함께 자바 프록시 모드에 대해 얘기를 나눠보도록 하겠습니다. 1. 정적 에이전트 1.1 정적 에이전트의 에이전트 클래스와 피에이전트의 클래스는 모두 공통된 인터페이스를 유지해야 한다. 1.2 프록시 클래스,...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.