Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //project.java
- import MULTISET;
- public class Bag<E extends Keyed> implements Iterable<E> {
- //cannot find symbol. symbol: class Iterator. location: class project.Bag<E>
- public Iterator<E> iterator() {
- return new ArrIterator(this);
- }
- //same error as above
- public class ArrIterator implements Iterator<E> {
- Bag<E> arr;
- int coun;
- public ArrIterator(Bag<E> arr) {
- this.arr = arr;
- this.coun = 0;
- }
- public boolean hasNext() {
- return this.coun < arr.cardinality();
- }
- public E next() {
- if (!hasNext()) {
- throw new NoItemException();
- }
- return arr.getArray()[coun+1];
- }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
- }
- //MULTISET.java
- //cannot find symbol. symbol: class Iterator. location: interface MultiSet<E>
- public interface MultiSet<E extends Keyed> extends Iterable<E> {
- public Iterator<E> iterator();
- }
- public class ArrIterator implements Iterator<E> {
- public Iterator<E> iterator() {
- return new ArrIterator(this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement