mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 00:58:24 +00:00
36 lines
953 B
Java
36 lines
953 B
Java
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());
|
|
}
|
|
}
|
|
}
|