Question

java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...

java. do it on eclipse. the same way its instructed

Second Inheritance OOP assignment

Outcome:

Student will demonstrate the ability to understand inheritance

Program Specifications:

Programming assignment: Classes and Inheritance

You are to pick your own theme for a new Parent class. You can pick from one of the following:

Person

Automobile

Animal

If you choose Person, you will create a subclass of Person called Student.

If you choose Automobile, you will create a subclass of Automobile called RaceCar

If you choose Animal, you will create a subclass of Animal called Horse

Once you pick your theme, you must use the “HAS A” question to determine the fields that you

are going to include in your classes.

For example, an Alarm Clock HAS A:

Set Hours Button Time

Set Minutes Button Time

Set Hours Button Alarm

Set Minutes Button Alarm

Alarm On-Off Button

Snooze Button

You will create UMLs for all classes.

You will WRITE JAVA code to create the classes from above. In the classes you are creating

you will include at least three fields or attributes (See sample alarm clock above).

You will have overloaded methods, and overridden methods. You will label each. You will

have a Testclass that creates at least 3 objects of each class.

Your parent and child classes need to have all necessary and required methods.

You will test your work. You will zip up the project folder (no design tool needed).

Submission Requirements:

You must follow the rules from the second assignment minus the design tool but

add the UML.

YOU CANNOT:

Use global variables

Use the word goto

Use the break command outside a case statement

0 0
Add a comment Improve this question Transcribed image text
Answer #1

plzzzzzzzzzzzzzzzzzzz Upvote...
Comment for any queries..thanks

I chose Animal Theme.



//Animal.java

public class Animal {

public int legs;

public int speed;

public String food;

// constructor animal

public Animal(int legs, int speed, String food) {

super();

this.legs = legs;

this.speed = speed;

this.food = food;

}

// method run

public void run()

{

System.out.println("Animal is running");

}

// Overloading content method

public void content(int legs, int speed)

{

System.out.println("Legs for this animal: "+legs+"\nSpeed of this animal is: "+speed);

}

// Overloading content method

public void content(int legs)

{

System.out.println("Legs for this animal: "+legs);

}

// Overloading content method

public void content(int legs, int speed, String food)

{

System.out.println("Legs for this animal: "+legs+"Speed of this animal is: "+speed+ "Food type of this animal is: "+food);

}

}

---------------------------------------------------------------------

//Horse.java

public class Horse extends Animal {

public Horse(int legs, int speed, String food) {

super(legs, speed, food);

// TODO Auto-generated constructor stub

}

@Override

public void run() {

// TODO Auto-generated method stub

System.out.println("Horse is running");

}

}


----------------------------------------------------------------------------

//Test.java

public class Test {

public static void main(String[] args) {

// TODO Auto-generated method stub

// creating Animal object

Animal a=new Animal(4,25,"Veg");

// creating horse objects

Horse h1=new Horse(4,66,"Veg");

Horse h2=new Horse(4,45,"Veg");

// creating horse object and referencing to animal

Animal h3=new Horse(4,72,"Veg");

// Calling overloaded method "content"

h1.content(h1.legs);

h1.content(h1.legs,h1.speed);

// Calling overriding method "run"

h3.run();

}

}




Sample Output in eclipse:




Add a comment
Know the answer?
Add Answer to:
java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...

    Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student will demonstrate the ability to use inheritance in Java programs. Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following: Person Automobile Animal Based on your choice: If you choose Person, you will create a subclass of Person called Student. If you choose Automobile, you will create...

  • What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that...

    What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that derives from a superclas:s ■ Demon "Declare a variable of the superclass type and assign it an instance of the subclass type strate polymorphic behavior Access the public members of the superclass type Notice how the overridden versions of the subclass type are called Notice how the subclass specific members are inaccessible "Create an array of superclass type and use a foreach loop to...

  • JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance...

    JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance and polymorphism. In this assignment we will use inheritance and polymorphism to solve a problem. Part (a) of the figure below shows a symbolic representation of an electric circuit called an amplifier. The input to the amplifier is the voltage vi and the output is the voltage vo. The output of an amplifier is proportional to the input. The constant of proportionality is called...

  • The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario...

    The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario is to design an online shopping system for a local supermarket (e.g., Europa Foods Supermarket or Wang Long Oriental Supermarket) and is mostly concentrated on the product registration system. Design and draw a UML diagram, and write the code for the following classes: ID: The identification number must start with 1 and follows with 6 numbers, e.g., “1123456”. Description, e.g. “Banana” Recommended Price per...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • Please help me with the following question. This is for Java programming. In this assignment you...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • the first question java code eclipse app the second question is java fx gui caculator please...

    the first question java code eclipse app the second question is java fx gui caculator please fast 1. Create project called "YourFirstName_QUID'. Eg. Aliomar_202002345 2. Create two package Q1 and Q2. 3. Add your name and studentID as comments on the top of each Java source file you submit. Question 1. Bookings APP [80 Points-six parts] Implement the following hotel booking system. Use the following class diagram to understand the structure of the system's classes, their attributes operations (or methods),...

  • Java I need help Q1: Suppose this is a legal assignment statement: Student obj1 = new...

    Java I need help Q1: Suppose this is a legal assignment statement: Student obj1 = new Book(); what is the relationship between Student and Book?    1 - Student has Book as a field    2 - Student is a subtype of Book    3 - No Relationship    4 - Book is a subtype of Student. Question2: Q2: What are the types involved in this statement: Vehicle v1 = new Car();    1- Car    2- new    3-...

  • Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due:...

    Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this assignment is to give you practice implementing your own classes. It also provides extra practice with arrays. Task Implement a class Task, which is used to represent a job that should be done. It should contain the following private fields: .name text description of what job should be done...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT