Camp: Vehicles list points to null:
vehicles is null, thus, can't use .add() in generateBusses() First make an Object in generateBusses() then fill with add(). Or make generateBusses() only add to an instance member (i.e. construct with ref with instance) Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
182e57afb4
commit
4dde706eda
@ -90,9 +90,10 @@ public class Campaign {
|
||||
|
||||
|
||||
public void generateBusses(int number){
|
||||
//TODO: discuss. Make new list or add to old list?
|
||||
vehicles = new ArrayList<Vehicle>();
|
||||
for (int i = 1; i <= number; i++) {
|
||||
vehicles.add(new Bus(10));
|
||||
|
||||
vehicles.add(new Bus(10));//Throws NullPtrEx
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user