import java.util.*; public class BinPack { private int[] data; // the data to be packed private Bin[] bin; // the bins to pack em into private int binCapacity; // the capacity of each bin private int numberOfItems; // number of items to pack private int numberOfBins; // number of bins you have private String id; // an idendification for the problem private boolean packed = false; public BinPack(int NumberOfItems, int NumberOfBins, int Capacity) { numberOfItems = NumberOfItems; numberOfBins = NumberOfBins; binCapacity = Capacity; id = "Unknown"; data = new int[numberOfItems]; bin = new Bin[numberOfBins]; for (int i=0;i0)) { return false; } return true; } // Is the packing produced legal? That is, does it // actually pack all the items in data into the bins // such that bin capacities are respected and no more than the // given number of bins is used? private void add(int binObject,int dataElemant) { bin[binObject].add(data[dataElemant]); data[dataElemant] = 0; numberOfItems--; } public void pack() { int itemcapacity = numberOfItems(); for(int i = 0; i