Question: Given the @D array in class AdoptionRunner: Pet [ ] [ ] pets = { { new Pet ( Dog , 2 )
Given the @D array in class AdoptionRunner: Pet pets new PetDog new PetDog new PetDog
new PetHamster new PetHamster new PetHamster
new PetBird new PetBird new PetBird; In the Adoption class, write the reversePets method to reverse the elements in the row at the parameter index in the D array pets. public class Adoption
private Pet pets; The D array of Pet objects
Initializes pets to the specified D array of Pet objects
public AdoptionPet pets
this.pets pets;
Returns the D array of Pet objects
public Pet getPets
return pets;
Reverses the row located at index by swapping the first
and last elements in the row
public void reversePetsint index
Returns a String containing the information for
each Pet object in the D array pets
public String toString
String result ; for int row ; row pets.length; row
for int col ; col petslength; col
result petsrowcol;
result
;
return result;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
