Generally it's good practice to have constructors with different arguments pass through to a single constructor. Right now it looks like your code is using different constructors in different places, but not really using the arguments to indicate how the loot box should be constructed.Try something like:
Lootbox(){
this(0, 0, true); // Supply default values for missing (optional) arguments and call the main constructor
}
Lootbox(int money){
this(money, 0, true);
}
Lootbox(int money, int weight){
this(money, weight, true);
}
// All the real initialization goes in this one:
Lootbox(int money, int weight, Boolean biased(){
this.price = money;
if(biased){
this.rarity = generateBias();
else{
this.rarity = generateRarity(weight); // Note: I'm guessing here... you should make sure it's consistent
}
}
Generally it's good practice to have constructors with different arguments pass through to a single constructor. Right now it looks like your code is using different constructors in different places, but not really using the arguments to indicate how the loot box should be constructed.Try something like:
Lootbox(){ this(0, 0, true); // Supply default values for missing (optional) arguments and call the main constructor }
Lootbox(int money){ this(money, 0, true); }
Lootbox(int money, int weight){ this(money, weight, true); }
// All the real initialization goes in this one: Lootbox(int money, int weight, Boolean biased(){ this.price = money; if(biased){ this.rarity = generateBias(); else{ this.rarity = generateRarity(weight); // Note: I'm guessing here... you should make sure it's consistent } }