[英]The constructor Vehicle(String[], int) is undefined
I'm very new with java and can't figure this out! 我对Java非常陌生,无法解决这个问题! this is how it should look like , but it gives me an error and i'm not sure if i have to convert it or not ! 这就是它的外观,但是它给了我一个错误,我不确定是否必须转换它! or i'm doing something else wrong!!! 否则我做错了其他事情!!!
here is my requirements: Assign values to variables using the provided vehicle data. 这是我的要求:使用提供的车辆数据为变量分配值。 Refer to the Data File Layout Information for information of accessing these vehicle data values. 有关访问这些车辆数据值的信息,请参阅数据文件布局信息。 1. speeds 1.速度
public class Bicycle extends Vehicle implements IOutput {
private static int speeds;
public Bicycle(String[] vehicleData) {
super(vehicleData,speeds); // get error: The constructor Vehicle(String[], int) is undefined
// or i should this one :
speeds = Convert.toInteger(vehicleData[0]);
}
here is the vehicle class 这是车辆类别
public Vehicle(String[] vehicleData) {
count++;
owner= new Owner(vehicleData);
setVehicleType(Convert.toInteger(vehicleData[0]));
make = vehicleData[1];
model = vehicleData[2];
color = vehicleData[3];
purchaseDate = vehicleData[4];
cost = Convert.toDouble(vehicleData[5]);
}
your constructor in your Vehicle class accepts only string[] and you are passing a string[] and an int. 您的Vehicle类中的构造函数仅接受string [],并且您正在传递string []和一个int。
change 更改
super(vehicleData,speeds); // get error: The constructor Vehicle(String[], int) is undefined
to 至
super(vehicleData); // your error'd now disappear
or declare speeds in your super class Vehicle . 或在超级战车中声明速度。
int speed;
public Vehicle(String[] vehicleData, int speed)
super
is calling the Vehicle
constructor, which accepts only a String, not a String and a int. super
正在调用Vehicle
构造函数,该构造函数仅接受一个String,而不接受String和一个int。
Change to this. 改成这个。
// remove static
int speed;
public Bicycle(String[] vehicleData) {
super(vehicleData);
speeds = Integer.valueOf(vehicleData[0]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.