added iterator sample

This commit is contained in:
Ilkka Seppala
2014-08-18 23:18:15 +03:00
parent 71d7c875d6
commit 91ed79e6bd
8 changed files with 184 additions and 0 deletions
@@ -0,0 +1,35 @@
package com.iluwatar;
public class App
{
public static void main( String[] args )
{
TreasureChest chest = new TreasureChest();
ItemIterator ringIterator = chest.Iterator(ItemType.RING);
while (ringIterator.hasNext()) {
System.out.println(ringIterator.next());
}
System.out.println("----------");
ItemIterator potionIterator = chest.Iterator(ItemType.POTION);
while (potionIterator.hasNext()) {
System.out.println(potionIterator.next());
}
System.out.println("----------");
ItemIterator weaponIterator = chest.Iterator(ItemType.WEAPON);
while (weaponIterator.hasNext()) {
System.out.println(weaponIterator.next());
}
System.out.println("----------");
ItemIterator it = chest.Iterator(ItemType.ANY);
while (it.hasNext()) {
System.out.println(it.next());
}
}
}