Define some interfaces and abstract classes

Assignment Help Computer Engineering
Reference no: EM132109237

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.

Reference no: EM132109237

Questions Cloud

Deal with the largest tensions at the convention : The compromises created in the Constitution to deal with the largest tensions at the Convention far from settled major issues facing the US
Write a java program that implements the flowchart : Write a java program that implements the flowchart of one of the five programs offered by ET department.
Create a brief outline of the steps you used for chapter : Create a brief outline of the steps you used for the in-chapter activity and hands-on projects.
Current or market gdp in 2016 : In a conversation, someone mentioned that "Australia's economic grew because current or market GDP in 2016 was 1.11 trillion and in 2017 it was 1.14 trillion".
Define some interfaces and abstract classes : In this project you will define some interfaces, abstract classes, and concrete classes, all placed in a specific package.
Understanding of lean project management concepts : n what ways would you have implemented lean project management for event - Identify and elaborate processes from PMBOK, PRINCE2, Organisational Management
Concept of the business cycle : Explain what Fred meant using the concept of the business cycle, durable and non-durable industries.
Write a single statement that assigns num_ones with the num : A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills.
Income or according to some other standard : Do you think a nation's output should be distributed according to income or according to some other standard (such as basic human need)?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Determine first two lines of the new file created by code

Determine the first two lines of the new file created by the code below. This exercise refers to the file Justices.txt that contains data about the Supreme Court justices, past and present.

  Create two columns layout

Pick any topic Write html &css code in which there is only one page but there is a header & two columns.

  Describe one practical application of asynchronous counter

What is the principle of operation of a bidirectional shift register? Describe one practical application of bidirectional shift register. What is the principle of operation of an Asynchronous Counter? Describe one practical application of Asynchron..

  Create a form button named create resume

Create a form button named Create Resume. When clicked this button should call a function that generates a new Web page displaying a resume based on the user input.

  Standard apis supported by the jaxp

Explain two standard APIs supported by JAXP (Java API for XML processing) and provide a comparison between two mechanisms.

  Recognize trends in mobile software development and

imagine you are employed as a senior software engineer in a company that designs and produces mobile software

  Describe a method for splaying and searching for x

Describe a method for splaying and searching for x in one downward pass. Each sub step now requires that you consider the next two nodes in the path down to x.

  Develop a web page about your favorite movie

Develop a Web page about your favorite movie that displays the movie name in an tag, a description of the movie in a paragraph and an unordered list.

  Design the application that would output payment coupons

Design the application that would output 12 payment coupons for each of the 15 apartments in each of the 20 buildings.

  What fields you believe would be primary keys

Be sure to include the field type and size. Please do not jump ahead and try to create tables. now I'm just looking for a list of fields. This is somewhat vague on purpose. I want you to decide what is required in the database.

  Select the most important component of an e-r model

Select the most important component of an E-R model and explain your reasons for choosing it.

  The ways to depict constraint graph

The ways to depict constraint graph? illustrate how splitting a domain can be used to solve this problem.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd