/** * Interface defintion for Bag * Adapted slightly from Carrano and Henry * @author GTowell * Created: July 2021 */ public interface BagOfPets { /** * The number of pets in the bag * @return the number of pets in the bag */ public int numberOfItems(); /** * true if there is at least one pet in the bag * @return true if there is at least one pet in the bag, false otherwise */ public boolean isEmpty(); /** * Put a pet into the bag * @param p the pet to be added to the bag * @return true if there is space in the bag for the pet, false otherwise */ public boolean add(Pet p); /** * Remove a pet from the bag * @return the removed pet, or null if the bag is empty */ public Pet remove(); /** * Remove a particular pet from the the bag. This will remove ALL instance of the pet * @param p the pet to be removed * @return true if there is at least one instance of the pet in the bag, false otherwise */ public boolean remove(Pet p); /** * Remove all pets from the bag */ public void clear(); /** * The number of instances of the given pet in the bag * @param p the pet to be counted * @return The number of instances of the given pet in the bag */ public int countOf(Pet p); /** * True if the given pet is in the bag, false otherwise * @param p the pet to check for * @return True if the given pet is in the bag, false otherwise */ public boolean contains(Pet p); /** * Print the contents of the bag. */ public void display(); }