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.

What is the finished code in java? The code to start is

below. package labPolymorphism; public class CircusDog extends Dog { public CircusDog(String b)

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 walking

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!