Create abstract class Pet , which is the abstract superclass of all animals.Declare a integer attribute called legs, which records the number of legs for this animal.Define a constructor that...


Create abstract class Pet , which is the abstract superclass of all animals.Declare a integer attribute called legs, which records the number of legs for this animal.Define a constructor that initializes the legs attribute.Declare an abstract method eat.Declare a concrete method walk that prints out something about how the animals walks (include the number of legs).Create the Dog class.The Dog class extends the Pet class.This class must include a String attribute to store the name and food of the petDefine a default constructor that calls the superclass constructor to specify that all dogs have 4 legs and name.override the eat and walk method.Create the Cat class that extends Pet.This class must include a String attribute to store the name of the pet, and a string to save food .Define a constructor that takes one String parameter that specifies the cat's name and food. This constructor must also call the superclass constructor to specify that all cats have four legs.Override walk method.Implement the eat method.Create the Fish class with fins, food this  also extends pet, Override the Pet methods to specify that fish can't walk and don't have legs, implement eat method.Create a PetOwner Class which represents a person who have pets, this class contain name, age, and pet , Provide appropriate methods for the class.Create an TestAnimals program:


Create an arraylist of type PetOwner and then by asking about type of pet one want add that type pet to the arraylist.


e.g.     if(choice== cat){


                 Cat cat=new Cat(“meow”);


                   PetOwner p=new PetOwner(“ali”,cat)’;


                    arraylist.add(p);


 }


Same for dog and fish, at the end print arraylist also call eat and walk methods.


Use Inheritance, Abstraction, in java Programming OOP to solve this question.

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here