diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index eec35fc..ab0c3bf 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/ArmoredVehicle/src/MapWithSetArmoredCarsGeneric.java b/ArmoredVehicle/src/MapWithSetArmoredCarsGeneric.java index 2b648ca..0f59f46 100644 --- a/ArmoredVehicle/src/MapWithSetArmoredCarsGeneric.java +++ b/ArmoredVehicle/src/MapWithSetArmoredCarsGeneric.java @@ -47,14 +47,15 @@ public class MapWithSetArmoredCarsGeneric { private ArrayList _places; - + private int _MaxCount; + Iterator iter = _places.iterator(); public SetArmoredCarsGeneric(int count) { - _places = new ArrayList(count); + _MaxCount = count; + _places = new ArrayList(); } public int getCount() { @@ -15,7 +18,8 @@ public class SetArmoredCarsGeneric { public int Insert(T armoredCar) { - return Insert(armoredCar, 0); + if(_places.size()+1 < _MaxCount) return Insert(armoredCar, 0); + else return -1; } public int Insert(T armoredCar, int position) @@ -50,17 +54,20 @@ public class SetArmoredCarsGeneric { public T Remove(int position) { - if (position < 0 || position >= getCount()) + if (position < 0 || position >= getCount() || _places.get(position) == null) return null; T armoredCar = _places.get(position); _places.set(position, null); return armoredCar; } - public T Get(int position) - { - if (position < 0 || position >= getCount()) - return null; - return _places.get(position); - } + + public T getMachine() + { + if(iter.hasNext()) + { + return iter.next(); + } + else return null; + } }