http://www.verejava.com/?id=16999137231072
Package Com.mediator.theory;public class testmediator{public static void Main (string[] args) {mediator Medi Ator=new Mediatorimpl (); Mediator.handle ("Rent"); Mediator.handle ("Sale"); }}package Com.mediator.theory;public interface mediator{public void handle (String content); Package Com.mediator.theory;public class Mediatorimpl implements mediator{private HouseOwner owner1; Private HouseOwner Owner2; Public Mediatorimpl () {owner1=new houserent (); Owner2=new Housesale (); @Override public void handle (String content) {if ("Rent". Equals (content)) {Owner1.act Ion (); } if ("Sale". Equals (content)) {owner2.action (); }}}package Com.mediator.theory;public interface houseowner{public void action (); Package Com.mediator.theory;public class Houserent implements houseowner{@Override public void action () { SYSTEM.OUT.PRINTLN ("The customer has come to rent"); }}package Com.mediator.theory;public class Housesale implements houseowner{@Override public void action () { SYSTEM.OUT.PRINTLN ("The customer has come to sell the house"); }}
http://www.verejava.com/?id=16999137231072
The mediator pattern for Java design Patterns