Consider the IntArrayBag data structure that is represented by the following UML. IntArrayBag -data:int[] -manyltems:int +IntArrayBag() +IntArrayBag(capacity:int) +add(element:int):void +countOcuurances(target:int):int +grab(index:i):int +remove(target:int):void +size():int +max():int +countEven():int +change(oldVal:int, newVal:int):int (1) Implement an instance method, called bagMax, in the IntArrayBag class that finds and return the maximum value in the bag. (2) 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 IntArrayBag 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 the same, it is only the number of occurrences of each element that must be the same. (3) Implement a static method, called sumEven, in the IntArrayBag class that takes one input parameter of type IntArrayBag. The method then calculates and returns the sum of all even elements in the bag. (4) Re-implement the static sumEven method, in the IntArrayBag class that takes one input parameter of type IntArrayBag. The method then calculates and returns the sum of all even elements in the bag.
Consider the IntArrayBag data structure that is represented by the following UML. IntArrayBag -data:int[] -manyltems:int +IntArrayBag() +IntArrayBag(capacity:int) +add(element:int):void +countOcuurances(target:int):int +grab(index:i):int +remove(target:int):void +size():int +max():int +countEven():int +change(oldVal:int, newVal:int):int (1) Implement an instance method, called bagMax, in the IntArrayBag class that finds and return the maximum value in the bag. (2) 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 IntArrayBag 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 the same, it is only the number of occurrences of each element that must be the same. (3) Implement a static method, called sumEven, in the IntArrayBag class that takes one input parameter of type IntArrayBag. The method then calculates and returns the sum of all even elements in the bag. (4) Re-implement the static sumEven method, in the IntArrayBag class that takes one input parameter of type IntArrayBag. The method then calculates and returns the sum of all even elements in the bag.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education