Part A: Create a class named Insect, which includes the following: 1. Attributes including:      a. A String named species      b. A double named weight 2. Get and Set methods for both attributes 3. A default constructor that initializes species to "NA" and weight to 0.0 4. A non-default constructor that takes a String and double argument and defines the corresponding attributes as those values. 5. A method named eat, which increases the weight by 1.   Part B: Create a subclass of the class Insect named Butterfly. 1. Include another double attribute named maxWeightToFly 2. Include get and set methods for this new attribute 3. Include a default constructor that initializes species to "NA", weight to 0.0, and maxWeightToFly to 0.0 4. Include a non-default constructor that takes a String and two double arguments and defines the corresponding attributes to those values. 5. Override the eat method so that it increases the weight by 0.5 instead of 1 6. Include a new method named isAbleToFly which compares the weight of the Butterfly to the maxWeightToFly. If the weight attribute is greater than the maxWeightToFly, it returns false. If the weight attribute is less than or equal to maxWeightToFly, it returns true

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Part A:

Create a class named Insect, which includes the following:

1. Attributes including:

     a. A String named species

     b. A double named weight

2. Get and Set methods for both attributes

3. A default constructor that initializes species to "NA" and weight to 0.0

4. A non-default constructor that takes a String and double argument and defines the corresponding attributes as those values.

5. A method named eat, which increases the weight by 1.

 

Part B:

Create a subclass of the class Insect named Butterfly.

1. Include another double attribute named maxWeightToFly

2. Include get and set methods for this new attribute

3. Include a default constructor that initializes species to "NA", weight to 0.0, and maxWeightToFly to 0.0

4. Include a non-default constructor that takes a String and two double arguments and defines the corresponding attributes to those values.

5. Override the eat method so that it increases the weight by 0.5 instead of 1

6. Include a new method named isAbleToFly which compares the weight of the Butterfly to the maxWeightToFly. If the weight attribute is greater than the maxWeightToFly, it returns false. If the weight attribute is less than or equal to maxWeightToFly, it returns true.

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education