java代码题,要能编译得出结果啊!

来源:百度知道 编辑:UC知道 时间:2024/05/15 08:09:45
程序描述:
编写一个抽象类Vehicle类(汽车类),包含:
属性:protected int Wheel; //汽车轮子个数
属性:protected int Weight; //汽车重量
构造方法:public Vehicle(int wheel,int weight){} //接收轮子个数和重量值
抽象方法:public abstract void Speak( ) //输出汽车的喇叭声音
编写一个Moveable接口,包含:
方法:double MoveSpeed(); //用于返回最大的行驶速度
编写Car(小轿车)类和Truck(卡车)类,都继承Vehicle类和实现Moveable接口;
编写测试类,打印输出小轿车和卡车的轮子个数、重量和喇叭声音以及最大行驶速度。
没办法了,没分悬赏了啊!
各位大哥大姐帮下忙啊!

public abstract class Vehicle {
protected int Wheel;
protected int Weight;
public Vehicle(int wheel,int weight){

}
public abstract void Speak();

}
public interface Moveable {
double MoveSpeed();
}
public class Car extends Vehicle implements Moveable{

public Car(){
super(4,1000);
super.Weight = 1000;
super.Wheel = 4;
}
public void Speak() {
System.out.println("Car speak");
}
public double MoveSpeed() {
return 250;
}
}
public class Truck extends Vehicle implements Moveable{
public Truck() {
super(4,2000);
super.Weight = 2000;
super.Wheel = 4;
}
public void Speak() {
System.out.println("Truck speak");
}
public double MoveSpeed() {
return 450;
}
}
public class TestVehicle {

/**
* @param args
*/
publi