/
Penguin.php
45 lines (41 loc) · 873 Bytes
/
Penguin.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
44
45
<?php
/*
* use the
*
* parent::
*
* resolution operator to access parent functions
* or properties
* */
require_once("Bird.php");
class Penguin extends Bird{
/*
* if Penguin re-defines (overrides)
* the parent Bird constructor,
* you may need to explictly invoke it
* in order to pass along the parameter values
*
* if Penguin does not re-define the constructor,
* this is not required
* */
public function __construct($eyeColor, $song){
/*
* explicitly call the parent constructor to ensure it is run
* */
parent::__construct($eyeColor, $song);
echo "<p>A Penguin is born!</p>";
}
/*
* add to the parent's functions
* */
public function swim(){
echo "<p>Swim swim...</p>";
}
/*
* override the parents functions...
* */
public function fly(){
echo "<p>Penguins don't fly. Good luck trying...</p>";
}
}
?>