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();
}
}