Question
Please modify the code to do the steps for Abstract.Java, Cat.Java, and Dog.Java AbstractAnimal.java package exercises.inheritence; /** * Represents the parent class. * * @author
Please modify the code to do the steps for Abstract.Java, Cat.Java, and Dog.Java
AbstractAnimal.java
package exercises.inheritence;
/** * Represents the parent class. * * @author * @version 1.0 * */ public abstract class AbstractAnimal {
/** * class field name of animal. */ private String myName;
/** * Parameterized constructor. * * @param theName parameter name */ public AbstractAnimal(final String theName) { this.myName = theName; }
/** * getter for myName. * * @return myName */ public String getMyName() { return myName; }
/** * Setter for myName. * * @param theName parameter. */ public void setMyName(final String theName) { this.myName = theName; } // Q1 create a function walk() -- print animal walks // Q2 create a overloaded function walk with parameter String -- print animal walks + string // Q3 create a abstract function talk()
}
Cat.Java package exercises.inheritence;
import inheritenceExample.Child3;
/** * Represents the child class. * * @author * @version 1.0 * */ public class Cat{
// Q1. extend the AbstractAnimal class // Q2. create a parameterized constructor with theName, it should call superclass // paramterized constructor // Q3. In the main method create an object of cat and call the overloaded walking method // with parameter "slow" // Q4. Add un-implemented abstract method from parent and print "meow". // Q5. call the talk method from main function
}
Dog.Java package exercises.inheritence;
/** * Represents the child class. * * @author * @version 1.0 * */ public class Dog {
// Q1. extend the AbstractAnimal class // Q2. create a parameterized constructor with theName, it should call superclass // paramterized constructor // Q3. In the main method create an object of dog and call the overloaded walking method // with parameter "fast" // Q4. Add un-implemented abstract method from parent and print "Woof". // Q5. call the talk method from main function }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started