public class Car {
private String name;
FDJ fdj;
WK wk;
public Car(FDJ fdj, WK wk) {
this.fdj = fdj;
this.wk = wk;
}
}
class FDJ{
String name;
String ml;
public FDJ(String name,String ml) {
this.name = name;
this.ml = ml;
}
public void show() {
System.out.println("发动机马力要大...");
}
}
class WK{
String color;
String type;
public WK(String color,String type) {
this.color = color;
this.type = type;
}
public void show() {
System.out.println("车型宝马X6系列,颜色自定义...");
}
}
流水线生产.................
public class TestCar {
public static void main(String[] args) {
//先造发动机对象
FDJ fdj = new FDJ("宝马X系发动机","500匹马力");
//再造外壳对象
WK wk = new WK("黑色","宝马X6车型外壳");
//组装汽车
Car car = new Car(fdj,wk);
car.fdj.show();
car.wk.show();
}
}