package com.liang;
public class Factory {
static Vei che=null;
public static Vei getVei(){
//根据条件需要事例车(Vei)对象
//if() che=new Car(bank,seat);
//
return che;
}
}
//车类
class Vei //我把abstract 去掉了 效果你看看!! 一样的啊 郁闷!!
{
String bank;//牌子
int seat ;//座位
private Vei(){}
public Vei(String bank,int seat){
this.bank=bank;
this.seat=seat;
}
}
//轿车
class Car extends Vei
{
public Car(String bank,int seat){
super(bank,seat);
}
}
//卡车
class Truck extends Vei
{
int load;//载重
public Truck(String bank,int seat,int load){
super(bank,seat);
this.load=load;
}
} |