Mediator.java
上传用户:hensond
上传日期:2021-12-27
资源大小:817k
文件大小:1k
- package com.company.section3;
- /**
- * @author cbf4Life cbf4life@126.com
- * I'm glad to share my knowledge with you all.
- * 中介者
- */
- public abstract class Mediator {
- //定义同事类
- protected ConcreteColleague1 c1;
- protected ConcreteColleague2 c2;
-
- //通过getter/setter方法吧同事类注入进来
- public ConcreteColleague1 getC1() {
- return c1;
- }
- public void setC1(ConcreteColleague1 c1) {
- this.c1 = c1;
- }
- public ConcreteColleague2 getC2() {
- return c2;
- }
- public void setC2(ConcreteColleague2 c2) {
- this.c2 = c2;
- }
-
- //中介者模式的业务逻辑
- public abstract void doSomething1();
- public abstract void doSomething2();
-
- }