classes outlined to the right. Show the statements required to complete the foll
ID: 3915556 • Letter: C
Question
classes outlined to the right. Show the statements required to complete the following a. Create a new ArrayBag of Po1 ynomials caled b an initial capacity of 12 bagt with pie woid Add 2 Polynomials to your AcrayBag (fewer statements' better here). b. Count and store the number of Polynomials with a degree of 10 in your ArrayBag c. add to the bag before t mus d. Determine the number of "Tree spots' in your bag-Le, the number of elements can you resize itself appropriate add() and growAsWeeded () methods for the generic bag lass described above, Use comments to state any assumptions you are makingExplanation / Answer
18) a) ArrayBag bag1 = new ArrayBag(12); b) bag1.add(new Polynomial(2)); bag1.add(new Polynomial(5)); c) int count = bag1.countOccurrences(new Polynomial(10)); d) int freeSpots = bag1.getCapacity() - bag1.size(); 19) public void add(E element) { growAsNeeded(); data[manyItems++] = element; } public void growAsNeeded() { if(data.length == manyItems) { Object[] newArray = new Object[manyItems * 2]; for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.