i don't know what else to say here. everything works.
Let's make our previous example more accurate and universal.
The order in which astronauts are added to the astronauts list won't always be known. In order to properly assign tasks to crew members, we need to determine who each astronaut is. To do this, in the performWork() method, iterate through all the astronauts in a loop. Use the instanceof operator to determine who each astronaut is and pass it as an argument to the corresponding method:
Human objects — to the pilot(Human human) method;
Dog objects — to the chartCourse(Dog dog) method;
Cat objects — to the research(Cat cat) method.
The performWork() method should work correctly regardless of the number of astronauts and the order in which they are added to the astronauts list.
Requirements:
The performWork() method should call pilot(Human human) for each Human object in the astronauts list.
The performWork() method should call chartCourse(Dog dog) for each Dog object in the astronauts list.
The performWork() method should call research(Cat cat) for each Cat in the astronauts list.
package en.codegym.task.pro.task17.task1705;
public class Human extends Astronaut {
public String getInfo() {
return "Human";
}
}
🤔🙄 :shrug: <- haven't found that smiley.
no clue anymore... my very last idea would be to fix a possible NullPointerException (when you add a null to the list)