java跪求大佬解答一道题?
2019-12-01
class Bicycle{
public String color;
public double weight;
public double trackWidth;
public String model;
public double price;
public Bicycle(String color, String model, double weight, double trackWidth, double price) {
super();
this.color = color;
this.model = model;
this.weight = weight;
this.trackWidth = trackWidth;
this.price = price;
}
public String toString() {
return "色彩:"+this.color+"; 车重:"+this.weight+"; 轮距:"+this.trackWidth+"; 车型:"+this.model+"; 车价:"+this.price;
}
}
public class RacingBike extends Bicycle{
private int varSpeed;
public RacingBike(String color, String model, double weight, double trackWidth, double price,int speed) {
super(color, model, weight, trackWidth, price);
this.varSpeed=speed;
}
public String toString() {
return super.toString()+"; 变速:"+this.varSpeed;
}
public static void main(String[] args) {
RacingBike rb=new RacingBike("白色","山地自行车",13,1.6,512,8);
System.out.println(rb);
}
}
它意思是你的文件名必须为RacingBike,不要使用Bicycle
2019-12-01