interface Coder {
public void code();
}
class Student implements Coder {
@Override
public void code() {
System.out.println("javase");
System.out.println("javaweb");
}
}
class HeiMaStudent implements Coder {
private Student s; //获取到被包装的类的引用
public ItcastStudent(Student s) { //通过构造函数创建对象的时候,传入被包装的对象
this.s = s;
}
@Override
public void code() { //对其原有功能进行升级
s.code();
System.out.println("数据库");
System.out.println("ssh");
System.out.println("安卓");
System.out.println(".....");
}
} |
|