Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Statistics

Authors: Prem S. Mann

8th Edition

9781118473986, 470904100, 1118473981, 978-0470904107

More Books

Students also viewed these Computer Network questions

Question

19. How do amphetamine and cocaine influence dopamine synapsespg105

Answered: 1 week ago