Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Animal Kingdom Begin by creating the inheritance structure found below, where Animal is an abstract class with an abstract method called makeSound(). This

image

The Animal Kingdom Begin by creating the inheritance structure found below, where Animal is an abstract class with an abstract method called makeSound(). This means that all the sub classes need to implement it. Facts can usually by found on Wikipedia (or similar place), but here are some explanations. In Bird there is an attribute called isMigrant which defines if the bird migrates during seasons (to warmer countries). For the same class, the attribute nestType defines where the bird is making a nest -- in a tree, on the ground, making a hole and so on. For the Reptile the attribute Habitat defines where the reptile lives, for example in water, in the desert, in mountains and so on. Make a small main that shows that the program works -- use correct and actual data. You can set data directly in your program, no need to ask the user for input. Print out some of the data, not the least the sound. Note that the different types of animals has a different way of sounding (saying, tweeting and hizzing). Below is an example of what can be outputted: A Swedish red and white cattle says: Muuuuu! A Peafowl tweets: Kaka-kaka A Comodo dragon hizzes: kshhhhhh kshhhh < Animal -name: String -latinName: String -weight: double #sound: String +makeSound(): String Bird Order in the Animal Kingdom Mammal Reptile -isMigrant: boolean In new package, as we want you to re-write the classes for practice, we want you to make the animals comparable. This means that we want you to implement the Comparable interface so that the animals can be compared lexically on the latin name. -furColor: String -habitat: String -canFly: boolean -nestType: String -hasWinterFur: boolean -isPoisonous: boolean Comparable Animal Store at least six animals in an ArrayList and sort it before printing out the latin name as well as: nest type for birds, fur colour for mammals and habitat for reptiles. This means that you need to check each object for which class it belongs before printing out the information. An example print out is shown below: Apteryx mantelli puts its egg in/on a whole in the ground Bos taurus has a fur that is red and white Chelonia mydas lives in the sea Crocodilus niloticus lives in fresh water Panthera tigris has a fur that is yellow and black Pavo cristatus puts its egg in/on a whole in the ground

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

Fundamentals Of Management

Authors: Stephen P. Robbins, Mary A. Coulter, David A. De Cenzo

11th Global Edition

1292307323, 978-1292307329

More Books

Students also viewed these Programming questions