Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93096706

Have any Question?


Related Questions in Computer Engineering

Analyze the time complexity of the following ternary search

Analyze the time complexity of the following ternary search algorithm: identify two points that subdivide a sorted array into three parts. If the given number is equal to one of these two points, we are done. Otherwise, ...

Is smartart graphic and table slide important for

Is Smartart graphic and Table slide important for PowerPoint Presentation? How would it benefit?

Simcon is a forensics software tool that can generate

SIMcon is a forensics software tool that can generate information for mobile device investigations. In Hands-On Project 12-1, you examined SMS messages on two phones that had been generated by SIMcon. In this project, yo ...

Answer the following questions whats the synchronous

Answer the following Questions : What's the synchronous distribution ? What are the guidelines for menu layout or list them?

Question can someone send me a complete produce a project

Question : Can someone send me a complete produce a project plan which results in the development of a major software product to solve a customer problem, for a Course Registration System.

Strings in cstrings manipulationwrite one main code with

Strings in C++ Strings manipulation Write one main code with the following functions. Toggle Write a function called toggle() that accepts a string, and an integer. The function checks whether the character at the positi ...

A chest has 3 drawers d1 has two silver coins s d2 has one

A chest has 3 drawers: (D 1 ) has two silver coins (S), (D 2 ) has one silver (S) and one gold (G), and (D 3 ) has two gold (G) coins. The drawer and coin were both randomly selected. Use the law of total probability to ...

Create login form to enter user name and a password textbox

Create login form to enter user name and a password textbox to enter password, and write procedure to simulate the process of triggering the login process after hitting the Enter Key.

It is required to design an iterative combinational circuit

It is required to design an iterative combinational circuit that computes the equation Z=2*X-Y, where X and Y are n-bit unsigned numbers. (i) Determine the number of inputs and outputs needed for your 1-bit cell. (ii) De ...

Serializationdesign a verilog module to convert a 64-bit

Serialization Design a Verilog module to convert a 64-bit data signal with periodic timing (eight-cycle period) into a series of eight-bit signals with periodic timing (one-cycle period). You must store the input data, a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As