Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the IntArrayBagdata structure that is represented by the following UML. -data:int[] -wauxitemus.int +IntArrayBag IntArrayBag +IntArrayBag(capacity:int) +add(element:int):void +countOcuurances(target:int):int +grab(index:i):int +remove(target:int):void +size():int +change(oldValint, newValint):int (1)
Consider the IntArrayBagdata structure that is represented by the following UML. -data:int[] -wauxitemus.int +IntArrayBag IntArrayBag +IntArrayBag(capacity:int) +add(element:int):void +countOcuurances(target:int):int +grab(index:i):int +remove(target:int):void +size():int +change(oldValint, newValint):int (1) Implement an instance method, called max, in the IntArrayBag class that finds and return the maximum value in the bag. (2) Implement a static method, called sumEven, in the IntArcaxBag class that takes one input parameter of type IntArrayBag. The method then calculates and returns the sum of all even elements in the bag. (3) Re-implement the sumEven method as an instance method (not static) in the IntArrayBag class. The method then calculates and returns the sum of all even elements in the bag. (4) Implement an instance method, called equals To, in the IntArrayBag's class that takes one input parameter and returns a Boolean value. The input parameter, called otherBag, is of type IntaxxaxBag as well. The method returns true if otherBag and the bag that activates the method have exactly the same number of every element. Otherwise the method return false. Note that the locations of the elements in the data arrays are not necessarily be the same, it is only the number of occurrences of each element that must be the same. (5) Re-implement the equals To method as a static method in the Driver class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started