runanimal
<p>import java.util.Scanner;</p>
<p>interface IAnimalActions {<br />
String makeSound();<br />
String eat();<br />
int getAverageAge();<br />
}</p>
<p>abstract class Animal implements IAnimalActions {<br />
// Any shared characteristics and methods of animals can be placed here<br />
}</p>
<p>class Bird extends Animal {<br />
public String makeSound() {<br />
return "Tweet-tweet!";<br />
}</p>
<p> public String eat() {<br />
return "Grain";<br />
}</p>
<p> public int getAverageAge() {<br />
return 5;<br />
}<br />
}</p>
<p>class Cat extends Animal {<br />
public String makeSound() {<br />
return "Meow";<br />
}</p>
<p> public String eat() {<br />
return "Fish";<br />
}</p>
<p> public int getAverageAge() {<br />
return 15;<br />
}<br />
}</p>
<p>public class RunAnimal {<br />
public static void main(String[] args) {<br />
Scanner scanner = new Scanner(System.in);<br />
System.out.print("Choose an animal (B for Bird, C for Cat): ");<br />
String choice = scanner.nextLine();</p>
<p> Animal selectedAnimal = null;</p>
<p> if ("B".equalsIgnoreCase(choice)) {<br />
selectedAnimal = new Bird();<br />
} else if ("C".equalsIgnoreCase(choice)) {<br />
selectedAnimal = new Cat();<br />
}</p>
<p> if (selectedAnimal != null) {<br />
System.out.println("Sound: " + selectedAnimal.makeSound());<br />
System.out.println("Food: " + selectedAnimal.eat());<br />
System.out.println("Age: " + selectedAnimal.getAverageAge());<br />
} else {<br />
System.out.println("No such animal found!");<br />
}<br />
<br />
scanner.close();<br />
}<br />
}<br />
</p>