Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called BugCollection whose main method creates both a Grasshopper and Bumblebee objects, calls the respireLungs and reproduceEggs methods of each object, calls

Write a class called BugCollection whose main method creates both a Grasshopper and Bumblebee objects, calls the respireLungs and reproduceEggs methods of each object, calls the jump method of the grasshopper and the protectHive method of the bumblebee.
I'm having trouble with the concept of inheritance and any help would be appreciated!
image text in transcribed
image text in transcribed
image text in transcribed
Implement the class hierarchy in the preceding UML given the following classes: class BodySection private String name; public BodySection(String s)[name =s:] public String toString() { return name;) class LongHindLegs (public String toString return "Long Hind Legs":)] class Stinger (public String toString [return "Stinger":}] Write a class called Bug Collection whose main method creates both a Grasshopper and Bumblebee objects, calls the respireLungs and reproduceEggs methods of each object, calls the jump method of the grasshopper and the protect Hive method of the bumblebee. Sample Run: ability to jump. A grasshopper is to a moneybee because ulars a Slinger and the ab FERRARI Insect -head: BodySection - thorax : BodySection - abdomen : BodySection + respireLungs(): void + reproduceEggs(): vold Grasshopper - longHindLegs: LongHindLegs + jump() : void Bumblebee - stinger: Stinger + protectHive(): void Figure 1 - UML for Insect and Subclasses protectHive method of the bumblebee. Sample Run: Demonstrate Grasshopper class using object hopper. An insect respires through lungs in its thorax. An insect reproduces by laying eggs from its abdomen. A grasshopper uses its Long Hind Legs to jump. Demonstrate Bumblebee class using object bumble. An insect respires through lungs.in its thorax An insect reproduces by laying eggs from its abdomen. A bumblebee uses its Stinger to protect the hive

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions