Code example for ListIterator

Methods: hasNextnextset

0
public class Production extends AbstractOrderCommand 
{ 
	@Override 
	public void exec( Race race, ListIterator<String> cmd, PrintWriter out ) throws GalaxyException
	{ 
		if( !cmd.hasNext() )
			throw new GalaxyException( "Required planet name" ); 
 
		Galaxy galaxy = race.getGalaxy();
		String planetName = galaxy.validIdentifier( cmd.next() );
		cmd.set( planetName );
		Planet planet = race.getOwnPlanet( planetName );
 
		if( !cmd.hasNext() )
			throw new GalaxyException( "Required production name" ); 
 
		String prodName = cmd.next();
		if( prodName.startsWith( "_" ) )
			prodName = prodName.substring( 0, 1 ) + galaxy.validIdentifier( prodName.substring( 1 ) );
		else 
			prodName = galaxy.validIdentifier( prodName );
		cmd.set( prodName );
		IProduction prod;
		if( "ship".equalsIgnoreCase( prodName ) )
		{ 
			if( !cmd.hasNext() )
				throw new GalaxyException( "Required ship type name" ); 
 
			prodName = cmd.next();
			if( prodName.startsWith( "_" ) )
				prodName = prodName.substring( 0, 1 ) + galaxy.validIdentifier( prodName.substring( 1 ) );
			else 
				prodName = galaxy.validIdentifier( prodName );
			cmd.set( prodName );
			ShipType shipType = race.findShipType( prodName );
			if( shipType == null )
				throw new GalaxyException( "Unknown ship type {0}", prodName );
 
			prod = new Ship_Production( shipType );
Connect your IDE to all the code out there  Get Codota for Java