Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The code for a class sa 1 1 oons has been started below. salloons depends on the class sa 1 1 discussed in the previous
The code for a class saoons has been started below. salloons depends on the class sa discussed in the previous question. A complete class ea is provided within the testing environment, so you should not add sall to the answer box below. Follow the links below to find the specifications of a constructor and two further methods that you should add to the code already given. a Balloons: public balloons Constructor for objects of class balloons. Initilises balloons to a suitable collection type. b categoriseBalloons: publc SortedMap categoriseBalloons Creates and returns a sorted map view of balloons. The keys are three categories of balloon in alphabetical order Large diameter greater than Medium diamater between and inclusive Small diameter less than Each of the associated values is a collection of ball objects that have diameters in the specified ranges, sorted by diameter from smalles to largest Returns: the sorted map c sumDiameters: public int sumDiametersSortedMap aSortedMap Sums rhe diameters of all the balloons in the given map. Note that other size categories may be introduced at a later date and this method should continue to work, regardless of the number of keys in the map. Parameters: aSortedMap a sorted map from ball sises to sorted sets of balls Returns: the sum of the diameters of all the balloons in the given map. Make any other alterations to the Balloons class required to implement the above methods.
The code for a class saoons has been started below. salloons depends on the class sa discussed in the previous question.
A complete class ea is provided within the testing environment, so you should not add sall to the answer box below.
Follow the links below to find the specifications of a constructor and two further methods that you should add to the code already given.
a Balloons: public balloons
Constructor for objects of class balloons. Initilises balloons to a suitable collection type.
b categoriseBalloons: publc SortedMap categoriseBalloons
Creates and returns a sorted map view of balloons. The keys are three categories of balloon in alphabetical order
Large diameter greater than
Medium diamater between and inclusive
Small diameter less than
Each of the associated values is a collection of ball objects that have diameters in the specified ranges, sorted by diameter from smalles to largest
Returns: the sorted map
c sumDiameters: public int sumDiametersSortedMap aSortedMap
Sums rhe diameters of all the balloons in the given map. Note that other size categories may be introduced at a later date and this method should continue to work, regardless of the number of keys in the map.
Parameters: aSortedMap a sorted map from ball sises to sorted sets of balls
Returns: the sum of the diameters of all the balloons in the given map.
Make any other alterations to the Balloons class required to implement the above methods.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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