import java.util.ArrayList; import java.util.List; public class SetGeneric { private final List _places; private final int _maxCount; public int Count; public int Count() { return Count; } public SetGeneric(int count) { _places = new ArrayList<>(); _maxCount = count; } public boolean Insert(T cruiser){ if(_places.size() == _maxCount) return false; Insert(cruiser, 0); return true; } public boolean Insert(T monorail, int position){ if (!(position >= 0 && position <= _places.size() && _places.size() < _maxCount)) return false; _places.add(position, monorail); Count++; return true; } public boolean Remove(int position) { if(!(position >= 0 && position < _places.size())) { return false; } _places.remove(position); Count--; return true; } public T Get(int position) { if (position < Count() && position >= 0) { return (T)_places.get(position); } return null; } }