Student will demonstrate the ability to utilize inheritance in a Java program. Student will demonstrate the ability to apply the IS A and HAS A relationships. Program Specifications: Start by watching Video Segment 16 from Dr. Colin Archibald's video series (found in the module overview).  Key in the program shown in the video and make sure it works. Then, add the following:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java Assignment

Outcomes:

  • Student will demonstrate the ability to utilize inheritance in a Java program.
  • Student will demonstrate the ability to apply the IS A and HAS A relationships.

Program Specifications:

Start by watching Video Segment 16 from Dr. Colin Archibald's video series (found in the module overview).  Key in the program shown in the video and make sure it works.

Then, add the following:

  • Animals have a Weight.
  • Animals have a Height.
  • Dog is an Animal.
  • Dogs have a Name.
  • Dogs have a Breed.
  • Dogs have a DOB.
  • Cat is an Animal
  • Cats have a Name.
  • Cats have 9 lives, so you need to keep track of the remaining lives once a cat dies.
  • Bird is an Animal
  • Birds have a wing span
  • Birds have a canFly which is true or false (some birds cannot fly)
  • Create a test class that creates one of each type of animal and displays the animal’s toString method.

Submission Requirements:

  • You must follow the rules from the prior assignments. UMLs and Design Tools are not required for this one.

YOU MAY NOT EVER:

  • Use global variables.
  • Use the word goto.
  • Use the break command outside a case statement.

Java Code from the video:  

//TestInheritance.java

public class TestInheritance {

   public static void main(String[] args) {
      
       Animal myPet = new Animal(12);
       System.out.println(myPet);

       Dog max = new Dog (34, "MAX ");
       max.setName("Maxwell: ");
       max.setWeight(56);
      
       System.out.println(max);
   }

}

//end of Testinheritance.java

//Animal.java

public class Animal extends Object {

       private int weight;

  
       public Animal (int weight) {
           super();
           setWeight (weight);      
       }
       public int getWeight() {
           return weight;
       }
       public void setWeight(int weight) {
           this.weight = weight;
       }
       public String toString () {
           String result;
           result = "I'm an animal weighing: " + weight;
           return result;
       }
      
}

//End of Animal.java

//Dog.Java

public class Dog extends Animal {

   private String name;
  
   public Dog(int weight, String name) {
       super(weight);
       setName(name);      
   }  
   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }
   public String toString() {
       String result;
       result = "Dog: " + name + super.toString();
       return result;
   }
}

//End of Dog.java

Please tell me in which .java file the code you created goes into. Please be sure if you decide that you want me to replace my code with yours the data from the original stays and that I can simply paste it into eclipse. Thank You!

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 8 steps with 8 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education