implement a printAnimals() method that provides easy-to-read output displaying the details of objects in an ArrayList.
I need help creating the printAnimal() method that prints from the menu, I keep getting somethings to print but not the full list and I cannot figure out what I am doing wrong. I have included pictures of the first part of the menu loop and the print menu
implement a printAnimals() method that provides easy-to-read output displaying the details of objects in an ArrayList.
- To demonstrate this criterion in a “proficient” way, your implemented method must successfully print the ArrayList of dogs or the ArrayList of monkeys.
- To demonstrate this criterion in an “exemplary” way, your implemented method must successfully print a list of all animals that are “in service” and “available”.
This is what I have so far for the method:
// Complete printAnimals
// Include the animal name, status, acquisition country and if the animal is reserved.
// Remember that this method connects to three different menu items.
// The printAnimals() method has three different outputs
// based on the listType parameter
// dog - prints the list of dogs
// monkey - prints the list of monkeys
// available - prints a combined list of all animals that are
// fully trained ("in service") but not reserved
// Remember that you only have to fully implement ONE of these lists.
// The other lists can have a print statement saying "This option needs to be implemented".
// To score "exemplary" you must correctly implement the "available" list.
public static void printAnimals(char option) {
if(option == '4') {
System.out.println(dogList);
}
else if(option == '5') {
System.out.println(Arrays.toString(monkeyList));
}
else if(option == '6') {
//Iterates through the dogs in the list
for(int i = 0; i < dogList.size(); i++) {
if(dogList.get(i).getTrainingStatus().equalsIgnoreCase("in service") && dogList.get(i).getReserved() == false) {
//prints out dogs that are in service and available
System.out.println(dogList.get(i));
}
}
//iterates through monkeys in the list
for(int i = 0; i < monkeyList.size(); i++) {
if(monkeyList.get(i).getTrainingStatus().equalsIgnoreCase("in service") && monkeyList.get(i).getReserved() == false) {
//prints monkeys that are in service and available
System.out.println(monkeyList.get(i));
}
}
}
}
}
can suggest you to just run small parts of code separately not the entire code once
Trending now
This is a popular solution!
Step by step
Solved in 2 steps