Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WeightedDie is the subclass extended from Die superclass. How do I create a cons

ID: 3798899 • Letter: W

Question

WeightedDie is the subclass extended from Die superclass. How do I create a constructor for WeightedDie with more parameters than the original die class. I want to pass in extra weightedSide n percent. 18 19 public WeightedDie super(); 20 21 24 25. public weightedDie(int aNumsides, int aweightedside,int aPercent)( 26 28 weighted side aweightedside, 29 30 //percentage in 100 31 percent a Percent; 32 percentGenerator new Random(); 33 roll(); 35 36 37 39 40 41 Goverride 42 public int roll()( 43 currentvalue super roll(); 45 chance percent Generator.nextInt(100) 1; 46 narcant

Explanation / Answer

1) You can write parameterized constructor like below.
2) Super() mehod will call parent class constructor.

public WeightedDie(int aNumSides, int aWeightedSide, int aPercent) {
super();
   numSides = aNumSides;
WeightedSide = aWeightedSide;
percent = aPercent;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote