Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. //project.java
  2. import MULTISET;
  3. public class Bag<E extends Keyed> implements Iterable<E> {
  4. //cannot find symbol. symbol: class Iterator. location: class project.Bag<E>
  5. public Iterator<E> iterator() {
  6. return new ArrIterator(this);
  7. }
  8. //same error as above
  9. public class ArrIterator implements Iterator<E> {
  10. Bag<E> arr;
  11. int coun;
  12. public ArrIterator(Bag<E> arr) {
  13. this.arr = arr;
  14. this.coun = 0;
  15. }
  16. public boolean hasNext() {
  17. return this.coun < arr.cardinality();
  18. }
  19. public E next() {
  20. if (!hasNext()) {
  21. throw new NoItemException();
  22. }
  23. return arr.getArray()[coun+1];
  24. }
  25. public void remove() {
  26. throw new UnsupportedOperationException();
  27. }
  28. }
  29. }
  30.  
  31. //MULTISET.java
  32. //cannot find symbol. symbol: class Iterator. location: interface MultiSet<E>
  33. public interface MultiSet<E extends Keyed> extends Iterable<E> {
  34. public Iterator<E> iterator();
  35. }
  36.  
  37. public class ArrIterator implements Iterator<E> {
  38.  
  39. public Iterator<E> iterator() {
  40. return new ArrIterator(this);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement