-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcat.php
More file actions
50 lines (46 loc) · 951 Bytes
/
cat.php
File metadata and controls
50 lines (46 loc) · 951 Bytes
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
44
45
46
47
48
49
50
<?php
interface Attribute {
function __toString();
}
abstract class Hair implements Attribute {}
class ShortHair extends Hair {
public function __toString() {
return "I have short hair.\n";
}
}
class LongHair extends Hair {
public function __toString() {
return "I have long hair.\n";
}
}
abstract class Eyes implements Attribute {}
class BrownEyes extends Eyes {
public function __toString() {
return "I have brown eyes.\n";
}
}
class GreenEyes extends Eyes {
public function __toString() {
return "I have green eyes.\n";
}
}
class BlueEyes extends Eyes {
public function __toString() {
return "I have blue eyes.\n";
}
}
class CatFactory {
private $Hair;
private $Eyes;
function __construct(Hair $hair, Eyes $eyes) {
$this->Hair = $hair;
$this->Eyes = $eyes;
}
function getHair() {
return clone $this->Hair;
}
function getEyes() {
return clone $this->Eyes;
}
}
?>