main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

interface Say {
	public function say();
}

abstract class Animal implements Say {
	protected $name;
	protected $nickname;
	protected $coloring;
	protected $breed;
	protected $age;

	public function __construct($name, $nickname, $coloring, $breed, $age) {
		$this->name = $name;
		$this->nickname = $nickname;
		$this->coloring = $coloring;
		$this->breed = $breed;
		$this->age = $age;
	}
}

class Dog extends Animal {
	public function say() {
		return "Я - {$this->name} {$this->coloring} окраса, породы - {$this->breed}, зовут меня - {$this->nickname}, мне сейчас {$this->age}";
	}
}
class Cat extends Animal {
	public function say() {
		return "Я - {$this->name} {$this->coloring} окраса, породы - {$this->breed}, зовут меня - {$this->nickname}, мне сейчас {$this->age}";
	}
}

$dog = new Dog('собака', 'Рекс', 'белого', 'Немец', '5 лет'); 
echo $dog->say();

echo "\n\n";

$cat = new Cat('кошка', 'Маркиза', 'пятнистого', 'Сфинкс', '2 года'); 
echo $cat->say();

?>
PHP 7.0.8 (cli) (built: Jun 23 2016 23:39:14) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies