#107 Iterator example JavaDoc
This commit is contained in:
parent
5831d3239d
commit
0d2e033df6
@ -2,13 +2,17 @@ package com.iluwatar.iterator;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Iterator (ItemIterator) adds abstraction layer on top of a collection
|
* Iterator ({@link ItemIterator}) adds abstraction layer on top of a collection
|
||||||
* (TreasureChest). This way the collection can change its internal
|
* ({@link TreasureChest}). This way the collection can change its internal
|
||||||
* implementation without affecting its clients.
|
* implementation without affecting its clients.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program entry point
|
||||||
|
* @param args command line args
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TreasureChest chest = new TreasureChest();
|
TreasureChest chest = new TreasureChest();
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar.iterator;
|
package com.iluwatar.iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Item
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
private ItemType type;
|
private ItemType type;
|
||||||
|
@ -2,7 +2,7 @@ package com.iluwatar.iterator;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Iterator interface.
|
* ItemIterator interface.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface ItemIterator {
|
public interface ItemIterator {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar.iterator;
|
package com.iluwatar.iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* ItemType enumeration
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum ItemType {
|
public enum ItemType {
|
||||||
|
|
||||||
ANY, WEAPON, RING, POTION
|
ANY, WEAPON, RING, POTION
|
||||||
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Collection class.
|
* TreasureChest, the collection class.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TreasureChest {
|
public class TreasureChest {
|
||||||
|
@ -2,6 +2,11 @@ package com.iluwatar.iterator;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* TreasureChestItemIterator
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TreasureChestItemIterator implements ItemIterator {
|
public class TreasureChestItemIterator implements ItemIterator {
|
||||||
|
|
||||||
private TreasureChest chest;
|
private TreasureChest chest;
|
||||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.iluwatar.iterator.App;
|
import com.iluwatar.iterator.App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Application test
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user