标签:
public interface ICar {
public void run();
}
public interface IDriver {
public void drive();
}
public class Benz implements ICar {
public void run() {
System.out.println("奔驰车在跑");
}
}
public class BMW implements ICar{
public void run() {
System.out.println("宝马车在跑!");
}
}
public class Driver implements IDriver{
private ICar mIcar;
public Driver(ICar car) {
mIcar = car;
}
public void drive() {
mIcar.run();
}
}
标签:
原文地址:http://www.cnblogs.com/zhangkefan/p/5496503.html