简体   繁体   English

构造函数Vehicle(String [],int)未定义

[英]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.

相关问题 构造函数AdPreferences(int,int,String)是未定义的startapp吗? - The constructor AdPreferences(int, int, String) is undefined startapp? “构造函数Window(int,int,String,Game)未定义” - “ The constructor Window(int, int, String, Game) is undefined ” 构造函数ClassCountry(String,String,String,int)未定义 - The constructor ClassCountry(String, String, String, int) is undefined 错误构造函数 Family(String, String, int) 未定义 - Error The constructor Family(String, String, int) is undefined 构造函数Item(int,String,double)是未定义的 - the constructor Item(int ,String ,double) is undefined 构造函数 Candidate(String, int[]) 是未定义的错误 - The constructor Candidate(String, int[]) is undefined error spring boot 中未定义构造函数 String, String, int, int, Optional&lt;&gt; - The constructor String, String, int, int, Optional<> is undefined in spring boot 构造函数 (int, int, string) 未定义; 在 LWJGL 中创建显示 - the constructor (int, int, string) is undefined; creating display in LWJGL Android Spinner问题-构造函数ArrayAdapter <String> (NewSRO,int,String [])未定义 - Android Spinner issue - The constructor ArrayAdapter<String>(NewSRO, int, String[]) is undefined 构造函数ServerSocket(int)未定义 - The constructor ServerSocket(int) is undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM