OK, it's Christmas time - so here we go with
the complete solution:
1. Take your current classes "Vehicle" and "Van" - those are looking quite fine now.
the new constructors are good (beside of that you missed the "int intWheels" to be set in "Van", but that does not harm the app until it is requested)
2. Delete the main function in "Van"
"Van" will be an object we are working with, but it will not execute code.
3. add another class beside of "Vehicle" and "Van"
The class "VehicleManagement" will now be the center of our fun:
public class VehicleManagement(){
ArrayList<vehicle> oVehicles = new ArrayList<vehicles>();
public VehicleManagement(){
this.ignition();
}
private void ignition(){
oVehicles.addAll(createVehicles());
System.out.println("Number of hired Vehicles: " + getHiredVehicles());
}
private List<vehicles> createVehicles(){
ArrayList<vehicles> oList = new ArrayList<vehicles>();
oList.add(new Van("PA-1000", "1968", "Chevy", false, 6, 20));
oList.add(new Van("PA-1001", "1969", "Chevy", false, 6, 20));
oList.add(new Van("PA-1002", "1970", "Chevy", false, 6, 20));
oList.add(new Van("PA-1003", "1971", "Chevy", false, 6, 20));
oList.add(new Van("PA-1004", "1972", "Chevy", false, 6, 20));
oList.add(new Van("PA-1005", "1973", "Chevy", true, 6, 20));
oList.add(new Van("PA-1006", "1974", "Chevy", true, 6, 20));
oList.add(new Van("PA-1007", "1975", "Chevy", true, 6, 20));
oList.add(new Van("PA-1008", "1976", "Chevy", true, 6, 20));
return oList;
}
private int getHiredVehicles(){
int iCountHired = 0;
for(Vehicle oVehicle: oVehicles){
if(true == oVehicle.getHired()){
iCountHired++;
}
}
return iCountHired;
}
public static void main(String[] args) {
VehicleManagement oManagement = new VehicleManagement();
}
}
You should understand this basics, as they are common used throughout programming.
Good books do not need to be expensive.
This:
Learning Java (Java Series) from o'reilly[
^] @ amazon.com would do the job just fine.
It's not up to date - and does not need to.
As you can see within the ratings it is well written and covers all topics for a beginning Java developer.
Get a new copy and do not just place it on the book shelf (every one owns such programming books that are hardly read...)
Books from o'Reilly are always worth a recommendation.