大神,帮帮忙,急求,不知道该怎么了

定义一个交通类工具类vehicle,其数据成员包括速度speed和种类kind;方法包括设置颜色setColor和取得颜色getColor。再设计一个子类Car,增加属性passenger表示可容纳旅客的人数,添加方法取得最大速度getMaxSpeed.

public class Vehicle {
private int speed; //成员速度
private int kind; //种类
private String color; //颜色
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
//构造方法
public Vehicle() {
super();
}
public static void main(String[] args) {
Car car=new Car();
car.setColor("红色");
System.out.println(car.toString());

}

}
class Car extends Vehicle{
private final static int passenge=50; //最多可容纳人数

//取得最大的速度
public int getMaxSpeed() {
return 100;
}
//打印结果
@Override
public String toString() {
return "最大速度为" + getMaxSpeed() + ","+"颜色="+getColor();
}
}
采纳吧,给点分吧

你随便找一个介绍面向对象的关于继承,多态等都有这个

 class  vehicle
{
    private int speed;
        private int kind;
        private int color;
        public void setColor(int value) { color = value; }
        public int getColor() { return color; }
}
class Car extends vehicle
{
    private int passenger;
        public void setpassenger(int value) { passenger = value; }
        public int getpassenger() { return passenger; }
        public int getMaxSpeed() { return 120; }
}

可是你的代码都是错误的啊,

定义一个交通类工具类vehicle,其数据成员包括速度speed和种类kind;方法包括设置颜色setColor和取得颜色getColor。再设计一个子类Car,增加属性passenger表示可容纳旅客的人数,添加方法取得最大速度getMaxSpeed.
public class Vehicle{
private int speed;
private String kind;
private Color r;

    public Vehicle(){}      //空构造器

    public Vehicle(int s, String k,Color r){   //带参构造器
        this.speed = s;
        this.kind = k;
        this.r = r;
    }

    public void setColor(Color r){
        this.r = r;
    }

    public Color getColor(){
        return this.r;
    }

}

class Car extends Vehicle{
private int passenger;
private static int youmeng = 0;//油门
private static final int MYM = 10; //最大的油门
private boolean cai = true; //是否加油门

public Car(int speed, String kind, Color r, int passenger){
        super(speed,kind,r);
        this.passenger = passenger;
}

public void setPassenger(int p){
        this.passenger = p;
}
public int getPassenger(){
        return this.passenger;
}

public static int getMaxSpeed(){
        if(cai){
                for(int i = 0; i<MYM; i++){
                        youmeng++;
                }
                cai = false;
        }
    return speed * youmeng; 
}

}

希望对您有帮助 谢谢