package CollectionGenericObjects; import java.util.ArrayList; import java.util.List; public class ListGenericObjects implements ICollectionGenericObjects { private List _collection; private int _maxCount; @Override public int Count() { return _collection.size(); } @Override public void SetMaxCount(int value, Class type) { if (value > 0) { _maxCount = value; } } public ListGenericObjects() { _collection = new ArrayList(); } @Override public int Insert(T obj) { if (Count() == _maxCount) return -1; _collection.add(obj); return Count(); } @Override public int Insert(T obj, int position) { if (Count() == _maxCount) return -1; if (position > Count() || position < 0) return -1; _collection.add(position, obj); return 0; } @Override public T Remove(int position) { if (position >= _maxCount || position < 0) { return null; } T myObj = _collection.get(position); _collection.remove(position); return myObj; } @Override public T Get(int position) { if (position >= Count() || position < 0) { return null; } return _collection.get(position); } }