Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Implement the ArrayStackOfIntegers ADT using arrays. Look at the API in the link below.
  2.  
  3.  
  4. LINK BELOW:
  5. import java.util.Iterator;
  6. import java.util.NoSuchElementException;
  7.  
  8. public class ArrayStackOfIntegers implements Iterable {
  9. private Integers[] items; // holds the items
  10. private int n; // number of items in stack
  11. public ArrayStackOfIntegers(int capacity) {
  12. items = (Integer[]) new Object[capacity];
  13. }
  14.  
  15. public boolean isEmpty() {
  16. ----
  17. }
  18.  
  19. public boolean isFull() {
  20. ----
  21. }
  22.  
  23. public void push(Integer item) {
  24. ----
  25. }
  26.  
  27. public Integer pop() {
  28.  
  29. }
  30.  
  31. public Iterator iterator() {
  32. return new ReverseArrayIterator();
  33. }
  34.  
  35. // an iterator, doesn't implement remove() since it's optional
  36. private class ReverseArrayIterator implements Iterator {
  37.  
  38. ----
  39. public void remove()
  40. {}
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement