Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.ArrayList; public class Shelter implements TestAnimals { private ArrayList myAnimal; static int numCats = 0; static int numDogs = 0; static int numReptiles =

import java.util.ArrayList; public class Shelter implements TestAnimals { private ArrayList myAnimal; static int numCats = 0; static int numDogs = 0; static int numReptiles = 0; public Animals() { myAnimal = new ArrayList(); } public void allAnimals() { for (Animal a1 : myAnimal) { System.out.println(a1); } } public boolean acceptAnimal(Animal new Animal) { boolean success = false; if (newAnimal instanceof Cat && numCats < CATSMAX) { Cat copyAnimal = new Cat((Cat) new Animal); myAnimal.add(copyAnimal); numCats++; success = true; } else (newAnimal instanceof Dog && numDogs < DOGSMAX) { myAnimal.add(newAnimal); numAnimal++; success = true; } else (newAnimal instanceof Reptile && numReptile < REPTILESMAX) { myAnimal.add(newAnimal); numAnimal++; success = true; } return success; } public boolean removeAnimal (int id) { boolean removed = false; for (int i = 0; i < myAnimal.size(); i++) { if (myAnimal.get(i).getId() == id) { if (myAnimal.get(i) instanceof Cat) numCats--; if (myAnimal.get(i) instanceof Dog) numDogs--; if (myAnimal.get(i) instanceof Reptile) numReptiles--; myAnimals.remove(i); removed = true; } } return removed; } public void allType(int animalType) { for (Animal a : myAnimal) { if (a instanceof Cat && AnimalType == 1) System.out.print(a); else (a instanceof Dog && AnimalType == 2) System.out.print(a); else (a instanceof Reptile && AnimalType == 3) System.out.print(a); } } }

//////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////

Can you write the javadocs for this?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago