|
Revision 39, 1.4 kB
(checked in by mikey, 2 years ago)
|
converted the TestConstructor? example
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
class ConstructorColor |
|---|
| 15 |
{ |
|---|
| 16 |
|
|---|
| 17 |
* the red part |
|---|
| 18 |
* |
|---|
| 19 |
* @var int |
|---|
| 20 |
*/ |
|---|
| 21 |
private $red = null; |
|---|
| 22 |
|
|---|
| 23 |
* the green part |
|---|
| 24 |
* |
|---|
| 25 |
* @var int |
|---|
| 26 |
*/ |
|---|
| 27 |
private $green = null; |
|---|
| 28 |
|
|---|
| 29 |
* the blue part |
|---|
| 30 |
* |
|---|
| 31 |
* @var int |
|---|
| 32 |
*/ |
|---|
| 33 |
private $blue = null; |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
* constructor |
|---|
| 37 |
* |
|---|
| 38 |
* @param int $red |
|---|
| 39 |
* @param int green |
|---|
| 40 |
* @param int blue |
|---|
| 41 |
*/ |
|---|
| 42 |
public function __construct($red, $green, $blue) |
|---|
| 43 |
{ |
|---|
| 44 |
$this->red = $red; |
|---|
| 45 |
$this->green = $green; |
|---|
| 46 |
$this->blue = $blue; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
* Returns the blue. |
|---|
| 51 |
* |
|---|
| 52 |
* @return int |
|---|
| 53 |
*/ |
|---|
| 54 |
public function getBlue() |
|---|
| 55 |
{ |
|---|
| 56 |
return $this->blue; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* Returns the green. |
|---|
| 61 |
* |
|---|
| 62 |
* @return int |
|---|
| 63 |
*/ |
|---|
| 64 |
public function getGreen() |
|---|
| 65 |
{ |
|---|
| 66 |
return $this->green; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
* Returns the red. |
|---|
| 71 |
* |
|---|
| 72 |
* @return int |
|---|
| 73 |
*/ |
|---|
| 74 |
public function getRed() |
|---|
| 75 |
{ |
|---|
| 76 |
return $this->red; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
* return a string representation |
|---|
| 81 |
* |
|---|
| 82 |
* @return string |
|---|
| 83 |
*/ |
|---|
| 84 |
public function __toString() |
|---|
| 85 |
{ |
|---|
| 86 |
return "R: " + $this->getRed() + " / G: " + $this->getGreen() + " / B: " + $this->getBlue(); |
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|
| 89 |
?> |
|---|