public class AoDi implements Car {
public void run() {
System.out.println("我是奥迪汽车..");
}
}
public class JiLi implements Car {
public void run() {
System.out.println("我是吉利汽车...");
}
}
public class JiLiFactory implements CarFactory {
public Car createCar() {
return new JiLi();
}
}
public class AoDiFactory implements CarFactory {
public Car createCar() {
return new AoDi();
}
}
public class Client {
public static void main(String[] args) {
Car aodi = new AoDiFactory().createCar();
Car jili = new JiLiFactory().createCar();
aodi.run();
jili.run();
}
}