- class LanXiang {
- public static void main(String[] args) {
-
- new Cai(new WaJueJi(new DianNao(new Ren()))).cai();
- }
- }
- class Ren {
- public void yong(){
- System.out.print("人用");
-
- }
- }
- class DianNao {
- Ren r ;
- public DianNao(Ren r){
- this.r = r;
- }
- public void kongZhi() {
- r.yong();
- System.out.print("电脑控制");
-
- }
- }
- class WaJueJi {
- DianNao dn;
- public WaJueJi(DianNao dn){
- this.dn = dn;
- }
- public void chao() {
- dn.kongZhi();
- System.out.print("挖掘机炒");
- }
- }
- class Cai {
- WaJueJi wjj;
- public Cai(WaJueJi wjj){
- this.wjj = wjj;
- }
- public void cai() {
- wjj.chao();
- System.out.print("菜");
- }
- }
复制代码 |
|