package logic; import java.util.ArrayList; import data.DerivativeType; import data.RawMaterial; /** * class to build raw materials * * @author Rukmal Fernando * @author Hardik Kotecha * @author Radhika Srinivasan */ public class Builder { private RawMaterial generatedRawMaterial; /** * default constructor * *Not yet implemented* * * @exception RuntimeException */ public Builder() { throw new RuntimeException( "Unable to instantiate default Builder." ); } /** * constructor * * @param pRawMaterialType : the type of the raw material to be built */ public Builder( DerivativeType pRawMaterialType ) { throw new RuntimeException("Builder(DerivativeType) is not implemented!"); } /** * Find all the subsets of variables of a certain length * * @param pVariables * @param pLength * @return list of clauses/subsets of length pLength given a set pVariables */ ArrayList> findAllSubsets( ArrayList pVariables, int pLength ) { //list to store all subsets ArrayList> allSubsets = new ArrayList>(); int[] indices; CombinationGenerator cg = new CombinationGenerator( pVariables.size(), pLength ); ArrayList combination; while ( cg.hasMore() ) { combination = new ArrayList(); indices = cg.getNext(); for ( int i = 0 ; i < indices.length ; i++ ) { combination.add( pVariables.get( indices[i] ) ); } allSubsets.add( combination ); } return allSubsets; } /** * get the generated raw material * * @return RawMaterial */ public RawMaterial getGeneratedRawMaterial() { return generatedRawMaterial; } /** * set the generated raw material * * @param pGeneratedRawMaterial : RawMaterial */ private void setGeneratedRawMaterial( RawMaterial pGeneratedRawMaterial ) { generatedRawMaterial = pGeneratedRawMaterial; } }