From the course: PHP: Design Patterns
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Challenge: Apply the factory pattern - PHP Tutorial
From the course: PHP: Design Patterns
Challenge: Apply the factory pattern
- In this challenge, I've already gotten you started with a simple skeleton. You should create a class called Shape, which has a Factory to create the right shapes that you need. Then each of those shapes should be able to return their own area. I've already set the include to be shape.php, so you should implement it there. This is a relatively short exercise, if you remember your geometry. And one side note, there's a PHP function called PI that you can use to retrieve the value automatically. When you've worked out your solution, don't forget to check the solutions video to see my particular answer.
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.