/**
* 研发部
*/
public class Development implements Department {
private Mediator m;//持有中介者(总经理)的引用
public Development(Mediator m) {
this.m = m;
m.register("development",this);
}
@Override
public void selfAction() {
System.out.println("加班狗,好好加班,写代码!!!");
}
@Override
public void outAction() {
System.out.println("向老板汇报,没钱了,需要资金支持研发工作!!!!");
m.command("finacial");
}
}
/**
* 财务部
*/
public class Finacial implements Department {
private Mediator m;//持有中介者(总经理)的引用
public Finacial(Mediator m) {
this.m = m;
m.register("finacial", this);
}
@Override
public void selfAction() {
System.out.println("数钱!给加班狗发工资");
}
@Override
public void outAction() {
System.out.println("向老板汇报,钱太多了!怎么花!!!!");
}
}
/**
* 市场部
*/
public class Market implements Department {
private Mediator m;//持有中介者(总经理)的引用
public Market(Mediator m) {
this.m = m;
m.register("market", this);
}
@Override
public void selfAction() {
System.out.println("在外面跑项目,接待客户,晚上准备配客户喝酒!");
}
@Override
public void outAction() {
System.out.println("向老板汇报,项目承接的进度,需要资金支持!!!!");
}
}
public class Client {
public static void main(String[] args) {
Mediator m = new President();
Development development = new Development(m);
Market market = new Market(m);
Finacial finacial = new Finacial(m);
development.selfAction();
development.outAction();
}
}