I have a car class which is as follows:
public class Car {
private String reg = null;
double[] tyre = {0.0,0.0,0.0,0.0};
public Car(String reg, double[] tyre) {
super();
this.reg = reg;
this.tyre = tyre;
}
public double calculateAverageTyrePressure() {
double p = tyre[0] + tyre[1] + tyre[2] + tyre[3];
return p/4.0;
}
}
and I have a test class where I have created an object and would like to give it 4 decimal values for it's tyre pressure but I can't figure out how to enter the values without getting an error as If i enter 4 decimal values it wants me to change my constructor to (String, double, double, double, double) which is not what the task says to do.
Test class:
public class CarTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Car car1 = new Car("V380 FEL", !!Need tyre values here!!);
}
}
P.S sorry If this seems like an easy question I've just started with Java and trying to learn.
new double[]{/* your values*/}?