LilasCorner / jlootbox

Other
1 stars 0 forks source link

Constructors for Lootbox are inconsistent and should be standardized #6

Open JohnTMurphy-NIU opened 2 years ago

JohnTMurphy-NIU commented 2 years ago

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 } }