Программа на php (Добавить конструкторы)

Forever_smile

Помогите пожалуйста дописать программу на php. Добавить конструкторы: частичный конструктор (введены только имя и курс, а тему и Id можно изменить) и пустой конструктор.
1.png

PHP:
  1. <?php
  2.   Class Student {
  3.     public $name;
  4.     public $kurs;
  5.     public $id;
  6.  
  7.     function __construct($name, $kurs, $id) {
  8.       $this->name = $name;
  9.       $this->kurs = $kurs;
  10.       $this->id = $id;
  11.     }
  12.     function setId($id)
  13.     {
  14.         $this->id = $id;
  15.     }
  16.     function print() {
  17.       echo «Name: {$this->name}, Kurs: {$this->kurs}, Id: {$this->id}«;
  18.     }
  19.   }
  20.   Class DiplomaStudent extends Student {
  21.     public $tema;
  22.  
  23.     function __construct($name, $kurs, $id, $tema) {
  24.       $this->tema = $tema;
  25.       parent::__construct($name, $kurs, $id);
  26.     }
  27.     function setTema($tema)
  28.     {
  29.         $this->theme = $theme;
  30.     }
  31.  
  32.     function print() {
  33.       echo «Name: {$this->name}, Kurs: {$this->kurs}, Id: {$this->id}, Tema: {$this->tema}«;
  34.     }
  35.   }
  36. $student = new DiplomaStudent(‘Лена’, 4, 6, ‘Программирование’);
  37. $student->print();
  38. ?>
 

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *