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 factory pattern

Challenge: Apply the factory pattern - PHP Tutorial

From the course: PHP: Design Patterns

Start my 1-month free trial

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.

Contents