A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,69 @@
|
|||
package hu.pj.obj;
|
||||
|
||||
public class Item {
|
||||
protected String name = "";
|
||||
protected int weight = 0;
|
||||
protected int value = 0;
|
||||
protected int bounding = 1; // the maximal limit of item's pieces
|
||||
protected int inKnapsack = 0; // the pieces of item in solution
|
||||
|
||||
public Item() {}
|
||||
|
||||
public Item(Item item) {
|
||||
setName(item.name);
|
||||
setWeight(item.weight);
|
||||
setValue(item.value);
|
||||
setBounding(item.bounding);
|
||||
}
|
||||
|
||||
public Item(int _weight, int _value) {
|
||||
setWeight(_weight);
|
||||
setValue(_value);
|
||||
}
|
||||
|
||||
public Item(int _weight, int _value, int _bounding) {
|
||||
setWeight(_weight);
|
||||
setValue(_value);
|
||||
setBounding(_bounding);
|
||||
}
|
||||
|
||||
public Item(String _name, int _weight, int _value) {
|
||||
setName(_name);
|
||||
setWeight(_weight);
|
||||
setValue(_value);
|
||||
}
|
||||
|
||||
public Item(String _name, int _weight, int _value, int _bounding) {
|
||||
setName(_name);
|
||||
setWeight(_weight);
|
||||
setValue(_value);
|
||||
setBounding(_bounding);
|
||||
}
|
||||
|
||||
public void setName(String _name) {name = _name;}
|
||||
public void setWeight(int _weight) {weight = Math.max(_weight, 0);}
|
||||
public void setValue(int _value) {value = Math.max(_value, 0);}
|
||||
|
||||
public void setInKnapsack(int _inKnapsack) {
|
||||
inKnapsack = Math.min(getBounding(), Math.max(_inKnapsack, 0));
|
||||
}
|
||||
|
||||
public void setBounding(int _bounding) {
|
||||
bounding = Math.max(_bounding, 0);
|
||||
if (bounding == 0)
|
||||
inKnapsack = 0;
|
||||
}
|
||||
|
||||
public void checkMembers() {
|
||||
setWeight(weight);
|
||||
setValue(value);
|
||||
setBounding(bounding);
|
||||
setInKnapsack(inKnapsack);
|
||||
}
|
||||
|
||||
public String getName() {return name;}
|
||||
public int getWeight() {return weight;}
|
||||
public int getValue() {return value;}
|
||||
public int getInKnapsack() {return inKnapsack;}
|
||||
public int getBounding() {return bounding;}
|
||||
} // class
|
||||
Loading…
Add table
Add a link
Reference in a new issue