A bag in java is a kind of collection that doesn’t do much more than contain its items. It does not order the items in any particular order and nor does it prevent duplicates. Develop a java interface named Bag that can store a certain number of whole numbers in it. Provide the following methods in the interface.
• getCurrentSize( ) that returns a count of numbers in the bag
• isEmpty( ) – that checks if the bag is empty
• add (int num) – adds a new number num to the bag
• remove (int num) – removes the first occurrence of the number num from the bag
• remove( ) – removes randomly a number from the bag
• clear( ) – removes all the numbers from the bag
• getFrequencyOf(int num) – counts the number of times the number num exists in the bag
• contains(int num) – Tests whether the bag contains the number num.
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments