Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Create a class named Bee. This class extends the Animal class (use the keyword extends to do so) and extends the interface FlyingAnimal

5. Create a class named Bee. This class extends the Animal class (use the keyword extends to do so) and

5. Create a class named Bee. This class extends the Animal class (use the keyword extends to do so) and extends the interface FlyingAnimal (use the keyword implements to do so). Open the editor and delete all the code placed in it automatically by BlueJ. a. wings: declare a new private attribute named wings. This attribute will store how many wings this animal has. b. Default constructor: Define a default constructor that takes no parameters. Have this constructor call the constructor of the superclass Animal (using the super keyword) to specify that all bees have 6 (six) legs. c. Parameterized constructor: Define a constructor that takes one int parameter named wingsNum which specifies the number of wings for a bee. This constructor must also call the superclass constructor (Animal) to specify that all bees have 6 legs. d. walk (): You do not have to re-implement this method for this class. Recall that this method is defined as a concrete method in class Animal, which means you can use the version implemented in the class Animal. e. eat(): This method is declared as an abstract method in the abstract class Animal therefore, any class extending Animal will have to implement this method. Provide your implementation for this method. This implementation should provide some description of what this animal eats. For example, in the case of class Bee, the eat () method can print out the following statement: Bee eats flower nectar. f. sound (): This method is declared as an abstract method in the abstract class Animal therefore, any class extending Animal will have to implement this method. Provide your implementation for this method. This implementation should provide some description of the sound this animal makes. For example, in the case of class Bee, the sound () method can print out the following statement: Bee sound is a zzz. Note: In the next steps you have to implement the FlyingAnimal interface methods for this class, since class Bee implements the FlyingAnimal interface. g. getWings (): is an abstract method defined in FlyingAnimal class. This method returns an int value of the private attribute wings and accepts no parameter. h. setWings (int wings): is an abstract method defined in FlyingAnimal class. This is a void method and accepts 1 parameter named wings to set the value of the private attribute wings. i. speed (): is an abstract method defined in FlyingAnimal class. Provide your implementation for this method, this method should print out the typical speed of this animal. For example, this method can print out the following statement: Bee speed is 6 miles/hour.

Step by Step Solution

3.45 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Below is a basic implementation of the described requirements in Java Animal class abstract class An... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

Prepare a cost of quality report.

Answered: 1 week ago