public long getPrice ( Configuration configuration ) { long total = 0 ; for ( KnapsackItem knapsackItem : getKnapsackItems ( ) ) { if ( configuration . valueAt ( knapsackItem . getIndex ( ) ) == 1 ) { total += knapsackItem . getPrice ( ) ; } } return total ; }
Returns price of items in given configuration .