|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Knapsack
public class Knapsack
Class for knapsack objects with a weight capacity
Constructor Summary | |
---|---|
Knapsack()
Constructor for objects of class Knapsack. |
|
Knapsack(double cap)
Constructor for objects of class Knapsack. |
Method Summary | |
---|---|
void |
addItem(double weight)
Adds an item of the given weight to the knapsack. |
double |
getCapacity()
Returns the weight capacity of the knapsack |
int |
getItemCount()
Returns the number of items in the knapsack |
double |
getTotalWeight()
Returns the total weight of the items in the knapsack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Knapsack()
public Knapsack(double cap)
Method Detail |
---|
public void addItem(double weight)
weight
- weight of the item to be addedpublic double getCapacity()
public int getItemCount()
public double getTotalWeight()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |