From the course: PHP: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Apply the strategy pattern - PHP Tutorial
From the course: PHP: Design Patterns
Challenge: Apply the strategy pattern
- In this challenge, I've given you some input, some structure and the desired output. You should create three classes. The name is already defined in the file to finish this challenge. The first class is a filter. And the other two are filtering strategies to apply. In this first snippet, we should get back even numbers: two, four, six, eight, 10. And from the second snippet, we should get back odd numbers: one, three, five, seven and nine. This challenge isn't much code, but the concept is a little more complex, so it might take you a little longer than some of the other challenges. No worries though, I've provided one potential solution in the solutions folder. Check it out when you're ready.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.