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.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here