ioc 实现
Public Class Lawyer
{
private IInfoSend infoSend;
{
private IInfoSend infoSend;
public IInfoSend setInfoSend(IInfoSend infoSend)
{
this.infoSend=infoSend;
}
{
this.infoSend=infoSend;
}
public void sendMsg()
{
this.infoSend.sendMsg(this.entity);
}
}
{
this.infoSend.sendMsg(this.entity);
}
}
Public Interface IInfoSend
{
void sendMsg();
}
public class BJInfoSendImp implement IInfoSend
{
{
private Ithird third;
public void setIthird(Ithird third)
{
this.third=third;
}
override void sendMsg()
{
third.doSomething(); }
}
{
third.doSomething(); }
}
void main()
{
{
BJInfoSendImp infosend=new BJInfoSendImp();
Ithird third=new Third();
infosend.setIthird(third);
law.setInfoSend(infosend);
law.sendMsg();
}
law.sendMsg();
}