Created
March 29, 2022 20:22
-
-
Save muratcakmaksoftware/9f08261568b52ffb4281d2de6707faae to your computer and use it in GitHub Desktop.
Open Closed Prenciple
This file contains hidden or 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
| <?php | |
| //Open Closed Principle | |
| abstract class Wing | |
| { | |
| public abstract function flap(); | |
| } | |
| class Car extends Wing | |
| { | |
| private $name; | |
| private $weight; | |
| function __construct($name) | |
| { | |
| $this->name = $name; | |
| } | |
| /** | |
| * Değişime kapalı | |
| */ | |
| public function getName() | |
| { | |
| return $this->name; | |
| } | |
| public function getWeight() | |
| { | |
| return $this->weight; | |
| } | |
| public function setWeight($weight) | |
| { | |
| $this->weight = $weight; | |
| } | |
| /** | |
| * Gelişime açık | |
| */ | |
| public function flap() | |
| { | |
| echo 'Car flapped its wings'; | |
| } | |
| } | |
| class Bird extends Wing | |
| { | |
| private $weight; | |
| /** | |
| * Değişime kapalı | |
| */ | |
| public function getWeight() | |
| { | |
| return $this->weight; | |
| } | |
| /** | |
| * Gelişime açık | |
| */ | |
| public function flap() | |
| { | |
| echo 'Bird flapped its wings'; | |
| } | |
| } | |
| $car = new Car('Murat131'); | |
| echo $car->flap().'<br/>'; | |
| $bird = new Bird(); | |
| $bird->flap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment