Question: 2. (XX points) Fill in the template below to make a complete class definition for a class that describes a pet adoption system. The system

 2. (XX points) Fill in the template below to make a
complete class definition for a class that describes a pet adoption system.
The system is implemented using an ArrayLists of pet names called pets

2. (XX points) Fill in the template below to make a complete class definition for a class that describes a pet adoption system. The system is implemented using an ArrayLists of pet names called pets and a count of pets that are adopted called numAdopted. So that there will not be confusion when adopting the class's constructor and mutator methods MUST be implemented with the strings in the list pets must always be unique. Make sure your code conforms to the instructions given in the comments for each method. Note: You are also being asked to write the code for a private helper method named getIndexOfPet. Make sure you are using this method in your accessors and mutators where appropriate to receive full credit! You may use the ArrayList methods on the back page when solving this problem. public class PetAdoption System private ArrayList pets; 17 List of pets private int numAdopted; // Number of pets adopted public PetAdoption System { 17 Constructor that takes no parameters. The initial list 11 of pets must be empty and the numAdopted must be zero. private int getIndexOfPet(String petName) { 77 Helper method that takes a String as a parameter and if the String // is in the list pets returns its index in the list. Otherwise // returns a -1. public shelter // Mutator method that takes a pet name as parameter. Returns false // if the pet is already in the list, otherwise adds the pet to the // end of the pet list and returns true. public lookup 1/ Accessor method that takes a String as a pet and if it is // in the pets list returns true. If it is not in the // players list returns false. TODO public adopt ) // Mutator method that takes a pet name. Returns false if the pet It is not already in the list, otherwise removes the pet name from 1 pets, increments numAdopted, and returns true. public get. NumAdopted ( // Accessor method that takes no parameters. Returns the number of // animals that have been adopted

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!