Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Implement the ArrayStackOfIntegers ADT using arrays. Look at the API in the link below.
- LINK BELOW:
- import java.util.Iterator;
- import java.util.NoSuchElementException;
- public class ArrayStackOfIntegers implements Iterable {
- private Integers[] items; // holds the items
- private int n; // number of items in stack
- public ArrayStackOfIntegers(int capacity) {
- items = (Integer[]) new Object[capacity];
- }
- public boolean isEmpty() {
- ----
- }
- public boolean isFull() {
- ----
- }
- public void push(Integer item) {
- ----
- }
- public Integer pop() {
- }
- public Iterator iterator() {
- return new ReverseArrayIterator();
- }
- // an iterator, doesn't implement remove() since it's optional
- private class ReverseArrayIterator implements Iterator {
- ----
- public void remove()
- {}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement