Question
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
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