Last active
December 22, 2018 10:58
-
-
Save vahid-almasi/657ddcd7d17e02bc8bf1eea0bb2b1346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
public function sum() { | |
foreach($this->shapes as $shape) { | |
if(is_a($shape, 'Square')) { | |
$area[] = pow($shape->length, 2); | |
} else if(is_a($shape, 'Circle')) { | |
$area[] = pi() * pow($shape->radius, 2); | |
} | |
} | |
return array_sum($area); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment