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

  Write r functions for forecasting future values

you will write R functions for forecasting future values of a time series, and apply them to observations on numbers of deaths and maximum temperatures in Houston, Texas.

  What is the latest status of the fire wire standard

What is the latest status of the Fire Wire standard? Is it going to succumb to the USB standard? Explain your response.

  Describe why data structure is helpful and important in

discuss why data structure is useful and important in programing. use your own examples to explain what an array is

  Interpreted code execute much more slowly than compiled code

interpreter mode and compiler mode), JavaScript and special case of interpretation of Java programs. Discuss the merits and weaknesses of interpreting, as opposed to compiling, and explain when and why they are used.

  Implement encryption-decryption procedures for rsa method

Implement encryption/decryption procedures for the RSA method (assume that s, p and N are all given and represented in arrays of integers of size 25).

  Advantage of the mesh to perform the summation

How much time does your algorithm take - how would you take advantage of the mesh to perform the summation in parallel? Give an algorithm.

  Contemporary information technology

Explain a contemporary information technology issue for which our society’s moral guidelines appear to be nonexistent or unclear.

  By using different internet sources find out an article or

using various internet sources find an article or website about attack prevention. show your personal content mastery

  Evaluate the business operations and network design

Write a 2 - 3 page paper evaluating the business operations and network design of your current organization or a previous employer (Preferably Retail Store but it is the Tutor's Choice).

  Define what is the difference between an insider attack

How would we determine what assets we have, what needs to be protected, and how to protect them

  Write a program that plays with the user the game

Write a program that plays with the user the game commonly known as Twenty Questions. Also the program will learn and improve from playing each game.

  Different areas of the web infrastructure

Discuss at least three different areas of the web infrastructure that are important to secure - how far would you go from an ethical and biblical point of view

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