Question: Bluej code: Complete the program below that implement the following requirements The Animal class defines the sound method. This method is an abstract and will

Bluej code:

Bluej code: Complete the program below that implement the following requirements TheAnimal class defines the sound method. This method is an abstract and

Complete the program below that implement the following requirements The Animal class defines the sound method. This method is an abstract and will be implemented by an animal class. public abstract String sound(); /** Return animal sound */ The Chicken class implements Edible to specify that chickens are edible. When a class implements an interface, it implements all the methods defined in the interface with the exact signature and return type. The Chicken class implements the howToEat method. Chicken also extends Animal to implement the sound method. The Animal class and Their inheritance relationship is shown in Figure 2.1 Animal Edible is a supertype for Chicken and Fruit. Animal is a supertype for Chicken and Tiger. Fruit is a supertype for Orange and Apple. interface Edible +howToEat(): String +sound(): String Fruit Chicken Tiger Orange Apple FIGURE 2.1 The Fruit class implements Edible. Since it does not implement howToEat method, Fruit must be denoted as abstract. The concrete subclasses of Fruit must implement the howToEat method. The Apple and Orange classes implement the howToEat method. The main method creates an array with objects and invokes the howToEat method if the element is edible and the sound method if the element is an animal. The Edible interface defines common behavior for edible objects. All edible objects have the howToEat method. Implement Animal class by Comparable interface and Cloneable Interface that implements two methods getWeight() and set Weight(). 1- Add the weight property in the Animal class with getter and setter methods 2- The two animals are compared based on their weights. Use the following main method to run your program. public static void main(String[] args) { Animal[] list = new Animal[5]; list[0] = new Chicken(); list[0].setWeight(4.5); list[1] = new Tiger(); list[1].set Weight(46.6); list[2] = new Chicken(); list[2].setWeight(1.5); list[3] = (Animal)(list[0].clone()); list[3].setWeight(7.5); list[4] = (Animal)(list[1].clone()); java.util.Arrays.sort(list); for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!