. Create abstract class Pet , which is the abstract super class of all animals. 1. Declare an integer attribute called legs, which records the number of legs for this animal. 2. Define a constructor that initializes the legs attribute. 3. Declare an abstract method eat. 4. Declare a concrete method walk that prints out something about how the animals walks (include the number of legs). 2. Create the Dog class that implements Pet class. 1. This class must include a String attribute to store the name and food of the pet 2. Define a default constructor that calls the super class constructor to specify that all dogs have 4 legs and name. 3. override the eat and walk method. 3. Create the Cat class that Implements Pet class. 1. This class must include a String attribute to store the name of the pet, and a string to save food . 2. Define a constructor that takes one String parameter that specifies the cat's name. This constructor must also call the super class constructor to specify that all cats have four legs. 3. Define another constructor that takes no parameters. Have this constructor call the previous constructor (using this keyword) and pass an empty string as the argument. 4. Override walk method. 5. Implement the eat method. 4. Create the Fish class with fins, food. Override the Pet methods to specify that fish can't walk and don't have legs, implement eat method. 5. Create a PetOwner Class which represents a person who have pets, this class contain name, age, and pet , Provide appropriate methods for the class. 6. Create an Test Animals 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

1. Create abstract class Pet , which is the abstract super class of all animals.
1. Declare an integer attribute called legs, which records the number of legs for this animal.
2. Define a constructor that initializes the legs attribute.
3. Declare an abstract method eat.
4. Declare a concrete method walk that prints out something about how the animals walks (include the number of legs).
2. Create the Dog class that implements Pet class.
1. This class must include a String attribute to store the name and food of the pet
2. Define a default constructor that calls the super class constructor to specify that all dogs have 4 legs and name.
3. override the eat and walk method.
3. Create the Cat class that Implements Pet class.
1. This class must include a String attribute to store the name of the pet, and a string to save food .
2. Define a constructor that takes one String parameter that specifies the cat's name. This constructor must also call the super class constructor to specify that all cats have four legs.
3. Define another constructor that takes no parameters. Have this constructor call the previous constructor (using this keyword) and pass an empty string as the argument.
4. Override walk method.
5. Implement the eat method.
4. Create the Fish class with fins, food. Override the Pet methods to specify that fish can't walk and don't have legs, implement eat method.
5. Create a PetOwner Class which represents a person who have pets, this class contain name, age, and pet , Provide appropriate methods for the class.
6. Create an Test Animals 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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY