In this project you will define some interfaces abstract


In this project you will define some interfaces, abstract classes, and concrete classes, all placed in a specific package.

You will also use the instanceofoperator. Note: if you do not use interfaces, abstract classes, and/or instanceof, you will not receive full credit.

Project description:

1. Define an interface called Nameable with the following methods:

String getName()

void setName(String name)

2. Define an interface called Runner with the following method:

void run()

3. Define an interface called Flyer with the following method:

void fly()

4. Define an abstract class called Animal which must implement the Nameable interface. Add the representation of:

Animal's name,

Animal's number of legs,

Animal's age, and

Keep count of the instances of the Animal class by using a static variable.

If you believe you should define a variable as static, or final, or even both, do so and briefly mention the reason as a comment on that variable in javadoc format (see below).

Use suitable qualifiers for all fields in the class.

5. Define a class called Dog, where a Dog is-a subclass of Animal. Also, a Dog can run (i.e. this class should implement the Runner interface).

6. Define a class called Cat, where a Cat is-a subclass of Animal. Also, a Cat can run (i.e. this class should implement the Runner interface).

7. Define a class called FlyCat, where a FlyCat is-a (imaginary) subclass of Animal that can fly (i.e. this class should implement the Flyerinterface).

8. Define a class called Dragon, where a Dragon is-a (imaginary) subclass of Animal that can both run and fly (i.e. this class should implement both the Runner and Flyer interfaces).

9. Each of the Animal subclasses has one or two capabilities: it can fly, or run, or both. When one calls fly on an animal that can fly, fly should print [name of the animal] + " is flying". Similarly run should print [name of the animal] + " is running".

10. Be creative and find more Animal kinds (at least two more). One of these new animal types (can be imaginary) should be able to both fly and run, and should be a direct subclass of Animal.

11. Create three animals of each type (3 dogs, 3 cats, etc), with different given names and suitable attribute values. The names can be as simple as Joe1, Joe2, etc.

12. Store the Animal objects (above) in an array of type Animal.

13. Display a menu to the user on the screen (before implementing this part, read the notes below).

Press 1 to see how many animals are in the system.

Press 2 to see the name and kind of each animal.

Press 3 to see which animals can fly.

Press 4 to see which animals can run.

Press 5 to see which animals can run AND fly.

Press 6 to see a description of each animal.

Press q to terminate the program.

14. Important notes about the menu:

If the user enters anything other than {1, 2, 3, 4, 5, 6, q}, the program should print a proper error message, and ask the user to enter a number between {1, 2, 3, 4, 5, 6} or 'q' (to quit). In other words, your program should not continue (or even worse, crash) if the user enters a wrong choice.

In option 1, the result should be the total number of instances of Animal class created so far (use the static variable).

For option 2, use instanceof to get kind.

For option 3, use instanceof. The result should contain both name (Joe1, Joe2, etc) and type (Dog, Cat, etc) of the animal.

For option 4, use instanceof.The result should contain both name and type (Dog, Cat, etc) of the animal.

For option 5, use instanceof. The result should contain both name and type (Dog, Cat, etc) of the animal.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: In this project you will define some interfaces abstract
Reference No:- TGS02902692

Expected delivery within 24 Hours