Question
What is the finished code in java? The code to start is below. package labPolymorphism; public class CircusDog extends Dog { public CircusDog(String b) {
What is the finished code in java? The code to start is below.
package labPolymorphism;
public class CircusDog extends Dog { public CircusDog(String b) { super(b); }
@Override public void move() { System.out.println("tightrope walking"); } }
package labPolymorphism;
public class Dog { private final String breed;
public Dog(String b) { breed = b; }
public void communicate() { System.out.println("bark bark"); }
public void move() { System.out.println("run"); }
public String getBreed() { return breed; } }
package labPolymorphism;
public class DogApp { public static void main(String[] args) { Dog myDog = new Dog("Greyhound"); actAsDog(myDog);
SledDog mySledDog = new SledDog("Husky"); actAsDog(mySledDog);
CircusDog myCircusDog = new CircusDog("Terrier"); actAsDog(myCircusDog); }
private static void actAsDog(Dog d) { d.communicate(); d.move(); System.out.println(); } }
package labPolymorphism;
public class SledDog extends Dog { public SledDog(String b) { super(b); }
public void pullSled() { System.out.println("pulling the sled"); } }
Lab Polymorphism CSIS-1410 Learning Objective Deepen your understanding of polymorphisnm Create an array of a superclass type Use the method getClass() to access the runtime class of the current object reed: S +communicate ( Practice the use of the instanceof operator SladDc Instructions: puilsledC Download the starter project from Canvas and unzip it in a folder with the same name. (If you change the folder name you will need to adjust the package name) Output 0 import the extracted ( unzipped) code files into Eclipse bark bark run You can do that like this: the Right-click the src folder that should include the new package > Import Import dialog opens bark bark run -Select General>File System and click Next the Import from directory bark bark tightrope walking dialog opens -Use the Browse button to navigate to the folder lablnheritance and click OK Output 1 Select the checkbox next to the folder lablnheritance Dog: Greyhound bark bark run IMPORTANT: Select the checkbox next to Create top-level folder Click Finish Run App to make sure that the file import worked as expected At this point the output should look like Output O SledDog: Husky bark bark run CircusDog: Terrier bark bark tightrope walkingStep 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