spaceAvailable[cargoType] -= trainAfter.getAmount(cargoType);
spaceAvailable[cargoType] -= cb.getAmount(cargoType);
    private int[] getSpaceAvailableOnTrain() {        //This array will store the amount of space available on the train for each cargo type.         int[] spaceAvailable = new int[w.size(KEY.CARGO_TYPES)];        //First calculate the train's total capacity.        for (int j = 0; j < train.getNumberOfWagons(); j++) {	    WagonType wagonType = (WagonType) w.get(KEY.WAGON_TYPES,		    train.getWagon(j));	    int cargoType = wagonType.getCargoType();            spaceAvailable[cargoType] += wagonType.getCapacity();        }        //Second, subtract the space taken up by cargo that the train is already carrying.        for (int cargoType = 0; cargoType < w.size(KEY.CARGO_TYPES);                cargoType++) {            spaceAvailable[cargoType] -= trainAfter.getAmount(cargoType);        }        return spaceAvailable;    }