Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ArrayBag<T> implements BagInterface<T>{
- private final T[] bag;
- private int numberOfItems;
- private static final int MAX_CAPACITY = 100;
- private static final int DEFAULT_CAPACITY = 20;
- public ArrayBag(){
- this(DEFAULT_CAPACITY);
- }
- Public ArrayBag(int capacity){
- if(capacity>MAX_CAPACITY){
- throw new IllegalStateException(“An ArrayBag is created with a capacity that exceeds the maximum capacity”);
- }
- @SuppressWarnings(“unchecked”)
- T[] temp = new Object[capacity];
- bag = temp;
- numberOfItems = 0;
- }
- @Override
- public boolean isEmpty() {
- return false;
- }
- //Other methods below
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement