package com.zyf.day21.other;
/**
*
* @author root
*练习:
* 一家三人工作
* 儿子:画画
* 母亲:画画 上色
* 父亲:装画框
*/
interface Work{
public void work();
}
class Son implements Work{
@Override
public void work() {
// TODO Auto-generated method stub
System.out.println("画画");
}
}
class Mather implements Work{
Work work;
public Mather(Work work){
this.work = work;
}
@Override
public void work() {
// TODO Auto-generated method stub
work.work();
System.out.println("给画上颜色。。。");
}
}
class Father implements Work{
Work work;
public Father(Work work){
this.work = work;
}
@Override
public void work() {
work.work();
// TODO Auto-generated method stub
System.out.println("给画上框。。。");
}
}
public class demo3 {
public static void main(String[] args) {
Son s = new Son();
s.work();
Mather m = new Mather(s);
m.work();
Father f = new Father(m);
f.work();
}
}