package path;

import java.util.Iterator;

public class ConcretePath implements Path{
    Iterator<String> pathIterator;
    int length;

    public ConcretePath(Iterator<String> pathIterator) {
        this.pathIterator = pathIterator;
        this.length = length();
    }

    @Override
    public Iterator<String> getPathIterator() {
        return pathIterator;
    }

    @Override
    public int length() {
        length = 0;
        while(pathIterator.hasNext()){
            length++;
            pathIterator.next();
        }
        return length;
    }
}

@@ -8,16 +8,44 @@
  path;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -115,53 +115,43 @@
     
-Iterator%3CString%3E pathIterator;%0A    int length
+private ArrayList%3CString%3E pathArray
 ;%0A%0A 
@@ -173,24 +173,25 @@
 etePath(
-Iterator
+ArrayList
 %3CString%3E
@@ -195,24 +195,21 @@
 ng%3E path
-Iterator
+Array
 ) %7B%0A    
@@ -225,63 +225,25 @@
 path
-Iterator = pathIterator;%0A        this.length = length()
+Array = pathArray
 ;%0A  
@@ -328,24 +328,32 @@
 urn path
-I
+Array.i
 terator
+()
 ;%0A    %7D%0A
@@ -405,146 +405,33 @@
     
-length = 0;%0A        while(pathIterator.hasNext())%7B%0A            length++;%0A            pathIterator.next();%0A        %7D%0A        return length;
+return pathArray.size();%0A
 %0A   

return Iterator from ArrayList.