Hello;
in the beginning i'm sorry for my weak language !!1
I have aquestion, I"m trying to write a program, but I have a problem with a method.
the method should do:
/**
* This method creates and adds new Race Car to Race Cars array.
* @param licensePlate
* @param year
* @param manufacturer
* @param model
* @param colour
* @param numDoors
* @param topSpeed
* @param totalRaces
* @return true if new car added successfully to race cars array,
false if array has no room for more cars.
*/
I wrote he method but It doesn't work correctly and doesn't add new RaceCar to the array, this is my code:
Code:public boolean addCarToArray(int licensePlate,int year, String
manufacturer, String model,Color colour,int numDoors, double
topSpeed, int totalRaces) {
if (carsArr.length<MAX_ARRAYS_LENGTH){
for (current_Length_Car_Array=0;current_Length_Car_Array<
MAX_ARRAYS_LENGTH;current_Length_Car_Array++){
if (carsArr[current_Length_Car_Array]==null){
carsArr[current_Length_Car_Array].getLicensePlate();
carsArr[current_Length_Car_Array].setLicensePlate(licensePlate);
carsArr[current_Length_Car_Array].getYear();
carsArr[current_Length_Car_Array].setYear(year);
carsArr[current_Length_Car_Array].getManufacture();
carsArr[current_Length_Car_Array].setManufacture(manufacturer);
carsArr[current_Length_Car_Array].getModel();
carsArr[current_Length_Car_Array].setModel(model);
carsArr[current_Length_Car_Array].getColor();
carsArr[current_Length_Car_Array].setColor(colour);
carsArr[current_Length_Car_Array].getNumDoors();
carsArr[current_Length_Car_Array].setNumDoors(numDoors);
carsArr[current_Length_Car_Array].getTopSpeed();
carsArr[current_Length_Car_Array].setTopSpeed(topSpeed);
return true;
}
else return false;
}
}
return false;
}

