Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA this is my code Duck.java public abstract class Duck { protected FlyBehavior flyBehavior; protected QuackBehavior quackBehavior; public Duck() {} public abstract void display(); public

JAVA

this is my code Duck.java

public abstract class Duck {

protected FlyBehavior flyBehavior;

protected QuackBehavior quackBehavior;

public Duck() {}

public abstract void display();

public abstract void performFly();

public abstract void performQuack();

public void swim() {

System.out.println("All ducks float, even decoys!");

}

public QuackBehavior getQuackBehavior() {

return quackBehavior;

}

public void setQuackBehavior(QuackBehavior quackBehavior) {

this.quackBehavior = quackBehavior;

}

public FlyBehavior getFlyBehavior() {

return flyBehavior;

}

public void setFlyBehavior(FlyBehavior flyBehavior) {

this.flyBehavior = flyBehavior;

}

}

----------------------------------------------

Add a new kind of quacking behavior called ShoutingQuack (implement it by having the duck say "QUACK QUACK!"

Create a new Duck subclass called LoudmouthDuck. When it quacks, it does a shouting quack.

At run time (in the test program), make the MallardDuck shout quack.

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago