. (4 marks) Consider the Polynomial and the generic ArrayBag classes outlined to
ID: 3915553 • Letter: #
Question
. (4 marks) Consider the Polynomial and the generic ArrayBag classes outlined to the right. Show the statements required to complete the following publie elass Aecaybag Create a new ArrayBag of Polynomials called bag1 with an initial capacity of 12 bjeot] data: int manytems pablie ArrayBeg (int initialcapecity) publio roid add CE lemant) public roid addiany (E... lementa) a. Pablie int countocourrences(E target) .. public int getcapacityD pablic boolean renove (E target) public int size) . publio void triatosinO .. publie String toString) private void growAstieded.. Add 2 Polynomials to your ArrayBag (fewer statements better here). b. publie class Polysonialt int degree; double coefficients: publio Polymonial (int degree).. public int getbegree)... public double evaluate (double x)... public void setcoefficient (int index, double coefficient).. Count and store the number of Polynomials with a degree of 10 in your ArrayBag. c. d. Determine the number of "free spots" in your bag-ie, the number of elements can you add to resize itself for the generic bag class described above, Use 19. (6 marksy) Witeappropriate ad() and growAs Needed0 methods 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();Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.