Question: Java ASAP An interface that describes the operations of a bag of objects. public interface BagInterface { Gets the current number of entries in this
An interface that describes the operations of a bag of objects. public interface BagInterface \{ Gets the current number of entries in this bag. greturn The integer number of entries currently in the bag. public int getcurrentsize(); J* Sees whether this bag is empty. greturn True if the bag is empty, or false if not. % public boolean isEmpty () ; /** Adds a new entry to this bag. eparam newEntry The object to be added as a new entry. ereturn True if the addition is successful, or false if not. * public boolean add ( T newentry); f** Removes one unspecified entry from this bag, if possible. Oreturn Either the removed entry, if the removal. public T remove(); /** Removes one occurrence of a given entry from this bag, if possible. Eparam anEntry The entry to be removed. Breturn True if the removal was successful, or false if not. public boolean remove( T anentry); /* Removes all entries from this bag. % public void clear (); /* Counts the number of times a given entry appears in this bag. eparam anEntry The entry to be counted. ereturn The number of times anEntry appears in the bag. % public int getFrequencyof ( T anEntry); \%* Tests whether this bag contains a given entry. eparam anEntry The entry to find. areturn True if the bag contains anEntry, or false if not. % public boolean contains(T anentry); \%* Retrieves all entries that are in this bag. greturn A newly allocated array of all the entries in the bag. Note: If the bag is empty, the returned array is empty. % public T[] toArray()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
