So here I have created a PolyLineIterator for my object PolyLine. Here is the code for the iterator
public class PolyLineIterator {
private int current = -1;
public PolyLineIterator() {
if(Polyline.this.vertices.length > 0 ) {
current = 0;
}
}
public boolean hasVertex() {
return current != -1;
}
public Point vertex() throws java.util.NoSuchElementException {
if(!this.hasVertex())throw new java.util.NoSuchElementException("end of iteration");
Point vertex = Polyline.this.vertices[current];
return vertex;
}
public void advance() {
if(current >= 0 && current < Polyline.this.vertices.length - 1) {
current ++;
}else {
current = -1;
}
}
}
When I am done typing the code an error pops up underlining Polyline and it says the following:-
No enclosing instance of the type Polyline is accessible in scope
How do I resolve this issue?