Question: please post the solution in java. i just need the solution of problem 2. Problem #1 (10 marks) a) Design and implement an abstract class

please post the solution in java. i just need the solution of problem 2.

Problem #1 (10 marks) a) Design and implement an abstract class called Animal that contains one instance variable of type String that stores the name of an animal (name) and appropriate accessor and mutator methods. Include a constructor that stores the name and toString() method to prints the animals name. The class also has two abstract methods, sound( ) and movement( ). The return type of the methods is String. b) Create 3 classes that inherit from Animal: Owl, Donkey, and Frog. Add an instance variable, age (int) to each of these classes. Develop a constructor that invokes the constructor of its parent class with a name and stores an age in each class. Create appropriate accessor and mutator methods for the age. Implement sound and movement methods in each class that return proper information: Owls hoot (sound) and fly (movement); donkeys hee-haw and walk; frogs ribbit and jump. Override toString() methods that returns a string of all information (including sound and movement information) in each class. c) Create an application/driver that thoroughly tests all methods of the 3 classes described in b).

Problem #2 (10 marks) a) Problem #2 is similar to Problem #1. But the Animal class is a regular class, not an abstract class. b) Add (or modify from Problem #1) the instance variable, name in the Animal class that is now accessible by each child class (Owl, Donkey, and Frog), i.e. we could have a red tailed hawk. The Animal class does not have sound() and movement() methods anymore. c) Add a get and set methods for the instance variable, name in the Animal class accessible by each child class. d) Owls have a wingspan: add that instance variable and a get and set method for it. e) Donkeys have a weight: add that instance variable and a get and set method for it. f) Frogs have a length: add that instance variable and a get and set method for it. g) Create an array of Animals containing at least 3 animals of each type (owls, donkeys and frogs). Using polymorphism, display the details of each animal in the array. (youll need to modify the toString methods from Problem #1) h) Use a cast to access the animals in the array to do sets and gets of wingspan, weight, and length. Show that the code works by producing suitable outputs.

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!