rendered paste bodypackage solutions;
import java.util.*;
import de.tu_darmstadt.es.sopra.exercises.Game;
import de.tu_darmstadt.es.sopra.model.external.factories.CommandFactory;
import de.tu_darmstadt.es.sopra.model.external.interfaces.scenario.ILocation;
import de.tu_darmstadt.es.sopra.model.external.interfaces.scenario.IScenario;
import de.tu_darmstadt.es.sopra.model.external.interfaces.scenario.IProductionFacility;
import de.tu_darmstadt.es.sopra.model.external.implementations.type.LocationType;
public class Solution12 extends Game {
private Vector<ILocation> p=new Vector<ILocation>();
private CommandFactory cmd =new CommandFactory();
@Override
public void planningPhase(IScenario arg0, int arg1) {
if(p.isEmpty())
finished();
while(!p.isEmpty()){
Iterator<ILocation> i=p.iterator();
while(i.hasNext()){
ILocation loc=i.next();
IProductionFacility pro=(IProductionFacility)loc;
if(!pro.hasCommand()){
int a = pro.getProducedGoodSet().getTotalQuantity();
int b = pro.getCapacity() -a;
if (b >0) {
try {pro.assignCommand(cmd.getProduceCommand(pro));}catch(Exception e){}
}else
p.remove(loc);
}
}
}
}
@Override
public void preparationPhase(IScenario arg0) {
getProductionFacilities(arg0);
}
/**
* Returns information of the team.<p>
*
* @return text with team information
* @since 08.11.2006
*/
public String getTeam(){
return "Team4";
}
/**
* Returns authors of this solution.<p>
*
* @return String array with author names
* @since 08.11.2006
*/
public String[] getAuthors(){
String[] Authors={"Ben Ghozi","Mahjoub","Dhif","Al Gauabra"};
return Authors ;
}
/**
* Returns version of this implementation.<p>
*
* @return version as text
* @since 08.11.2006
*/
public String getVersion(){
return "3.11.07";
}
private void getProductionFacilities(IScenario arg0){
Hashtable<String ,ILocation> hash= arg0.getLocations();
Enumeration<ILocation> e=hash.elements();
while(e.hasMoreElements()){
ILocation loc =e.nextElement();
if(loc.getType()==LocationType.PUMP||loc.getType()==LocationType.CORNFIELD||loc.getType()==LocationType.HOPFIELD||loc.getType()==LocationType.BARMFACILITY)
p.add(loc);
}
}
}