/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scripts/oop-practice-sources/php/figure.php
35 строк
658 B
Spirzen
OOP
09 июн 2026, 20:58
09 июн 2026, 20:58
1dca232
Код
Авторство
О чём код?
<?php class Figure { public function __construct( private string $name, private string $color ) {} public function describe(): void { echo "Фигура «{$this->name}», цвет: {$this->color}\n"; } } class Circle extends Figure { public function __construct(string $color) { parent::__construct('Круг', $color); } } class Square extends Figure { public function __construct(string $color) { parent::__construct('Квадрат', $color); } } $circle = new Circle('красный'); $square = new Square('синий'); $circle->describe(); $square->describe();