Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

What has been your desire for leadership in CVS Health?

Answered: 1 week ago

Question

Question 5) Let n = N and Y Answered: 1 week ago

Answered: 1 week ago