聊聊语音聊天室下载:一个java程序题

来源:百度文库 编辑:高校问答 时间:2024/05/07 08:07:18
class Vehicle{
public float speed;
public float direction;
public String ower;
public Vehicle(float s,float t,String o){speed=s; direction=t; ower=o;}
}

class PassengerVehicle extends Vehicle{
public static int toseats=80;
public static int occupied=0;
public static int occupied(){return occupied++;}
public static void PassengerVehicle(float s,float t,String o){Vehicle(float s,float t,String o);occupied();}
public static int cavailseats(){return toseats-occupied;}

public static void main(String[] args){
Vehicle mycar = new Vehicle(100.12f,45.6f,"zhangxingxing");
System.out.println("Vehicle"+" " +mycar.speed+" "+mycar.direction+" "+mycar.ower);
PassengerVehicle passenger1=new PassengerVehicle();
PassengerVehicle passenger2=new PassengerVehicle();
System.out.println("the available seats are"+" "+PassengerVehicle.cavailseats());
System.out.println("the occupied seats are"+" "+PassengerVehicle.occupied());
}
}

哪位高手帮我分析分析,错在哪,编译不了。我想实现的功能是通过类的继承,在继承类中实现输出可用座位和已经占用的座位的个数

class PassengerVehicle extends Vehicle{
这个子类继承的时候只继承父类的不带参数的构造方法,就是默认的那种构造方法,所以在父类里要加上public Vehicle(){ }
另外public static void PassengerVehicle(float s,float t,String o){Vehicle( s, t,o);occupied();}
什么意思看不懂