Answered step by step
Verified Expert Solution
Link Copied!

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 sa11oons has been started below. salloons depends on the class sa11 discussed in the previous question.
A complete class ea11 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 10)
Medium ( diamater between 5 and 10(inclusive))
Small ( diameter less than 5)
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 sumDiameters(SortedMap> 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions