I need help creating the printAnimal() method that prints from the menu, I keep getting errors 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(Scanner scnr) { if (scnr == "4") { System.out.println(dogList); } else if(scnr == '5') { System.out.println(monkeyList); } else if (scnr == '6') { //iterates through dog list for (int i = 0; i < dogList.size(); i++){ if (dogList.get(i).getTrainingStatus().equals("in service") && dogList.get(i).getReserved() == false) { System.out.println(dogList.get(i)); } } for(int i = 0; i < monkeyList.size(); i++) { if (monkeyList.get(i).getTrainingStatus().equals("in service") && monkeyList.get(i).getReserved() == false) { System.out.println(monkeyList.get(i)); } } } } }
I need help creating the printAnimal() method that prints from the menu, I keep getting errors 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(Scanner scnr) {
if (scnr == "4") {
System.out.println(dogList);
}
else if(scnr == '5') {
System.out.println(monkeyList);
}
else if (scnr == '6') {
//iterates through dog list
for (int i = 0; i < dogList.size(); i++){
if (dogList.get(i).getTrainingStatus().equals("in service") && dogList.get(i).getReserved() == false) {
System.out.println(dogList.get(i));
}
}
for(int i = 0; i < monkeyList.size(); i++) {
if (monkeyList.get(i).getTrainingStatus().equals("in service") && monkeyList.get(i).getReserved() == false) {
System.out.println(monkeyList.get(i));
}
}
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images