public abstract class CountryIterator
extends java.lang.Object
The real power of CountryIterators is that they can be chained together. For example
CountryIterator foo = new PlayerIterator(0, new ContinentIterator(1, new NeighborIterator(5, countries)));
Will return an enumeration of all the countries owned by player 0 that are in continent 1 and border couuntry 5
The only difference among the subclasses provided is the constructor, which all take different parameters.
All subclasses must:
1. Have a constructor that sets the class variable countries to an array of Countries (usually it's all the countries in the game). The constructor must call getNextReady() as its last action.
2. implement the
abstract protected boolean isAHit( int code );
method, with code being the array index of the country to check to see if it should be returned.
Constructor and Description |
---|
CountryIterator() |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Whether or not the Iterator contains more Countrys
|
Country |
next()
Removes the next Country from the Iterator and returns it.
|
public boolean hasNext()
public Country next()