package iterator.lab;

import java.util.function.Predicate;



public class NameRepository implements Aggregate {

	private String names[][] = { { "ashraf", "ezzat", "elsayed" }, { "david", "Nyaika" }, { "Yongchao", "Zhang" } };

	public void add(String firstName, String lastName) {

	}

	@Override
	public Iterator getIterator() {

		return new NameIterator();

	}

	private class NameIterator implements Iterator {

		Predicate<String> checkString = (s) -> s.equals("-");
		int index, yindex;

		@Override
		public boolean hasNext() {
			return (index < names.length && yindex < names[index].length);
		}

		@Override
		public Object next() {
			if (hasNext()) {
				yindex++;
				String nextName = names[index][yindex];
				if (yindex == names[index].length)
					index++;
				if (!checkString.test(nextName))
					return nextName;
				else
					return next();
			}
			return null;
		}

	}

}

@@ -58,20 +58,16 @@
 ate;%0D%0A%0D%0A
-%0D%0A%0D%0A
 public c
@@ -159,13 +159,9 @@
 %22, %22
-ezzat
+-
 %22, %22
@@ -689,23 +689,8 @@
  %7B%0D%0A
-%09%09%09%09yindex++;%0D%0A
 %09%09%09%09
@@ -726,16 +726,18 @@
 %5D%5Byindex
+++
 %5D;%0D%0A%09%09%09%09
@@ -770,16 +770,18 @@
 .length)
+ %7B
 %0D%0A%09%09%09%09%09i
@@ -789,16 +789,41 @@
 dex++;%0D%0A
+%09%09%09%09%09yindex = 0;%0D%0A%09%09%09%09%7D%0D%0A
 %09%09%09%09if (

solve Iterator lab