7.2 Overview and Strategy Pattern Lab

Overview

7.2 Overview and Strategy Pattern Lab

This assignment is based on the Duck example in Head First Design Patterns (p. 1-24)

Work through the stories in order. Use the acceptance criteria to check each feature, and complete the nested tasks using the specified names, values, and scenarios.

Open the duck simulator
1.Download and extract the start code.

7.2 Strategy LastName.zip

7.2 Strategy LastName.zip

There is a build error in the start code that is intentional.

A Download and extract the start code.
Compose ducks with interchangeable behaviors
Acceptance Criteria
Acceptance criteria
  • Duck declares abstract Display and concrete descendants override it.
  • The model includes MallardDuck, RedheadDuck, RubberDuck, and DecoyDuck.
  • FlyNoWay, IQuackBehavior, Quack, Squeak, and MuteQuack are defined and assigned to appropriate ducks.
  • The list contains all four duck types and DisplayDuckInfo shows each duck’s type, swimming, flying, and quacking behavior.
Instructions
2.Fix the build error by defining an abstract display method in the Duck class and overriding it in its descendant class.
A Fix the build error by defining an abstract display method in the Duck class and overriding it in its descendant class.
3.Add the following types of ducks:

RedheadDuck RubberDuck DecoyDuck

A Add the following types of ducks:
4.Add the following behaviors:

FlyNoWay IQuackBehavior (interface) Quack Squeak MuteQuack

A Add the following behaviors:
5.Add functionality to the code with the following rules:
A Create a MallardDuck, RedheadDuck, DecoyDuck, and RubberDuck and add them to a list.
B Iterate through the list of ducks, calling DisplayDuckInfo
C The console should print out the type of duck, its swim behavior, its fly behavior, and its quack behavior. The end result…

The console should print out the type of duck, its swim behavior, its fly behavior, and its quack behavior. The end result should look similar to the snip below:

End Duck Result for 7.2 Overview and Strategy Pattern Lab. Use the adjacent task instructions to identify the required controls, output, or debugger values.
End Duck Result
Completion review
6.Review the feature acceptance criteria
A Confirm the required results

Return to each story and verify its acceptance criteria. Preserve the submission format and destination stated in the activity; a reading, setup guide, lab, video demonstration, and oral final may require different evidence.

Compose ducks with interchangeable behaviors