-
Notifications
You must be signed in to change notification settings - Fork 0
/
ship.php
74 lines (62 loc) · 1.3 KB
/
ship.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* Author : Elka
*/
abstract class AbstractShip
{
protected $model = 'Motor';
protected $engine = 'Motor';
protected $capacity = 80;
protected $topSpeed = 100;
public function getModel()
{
return 'Perahu '.$this->model;
}
public function getEngine()
{
return $this->engine;
}
public function getCapacity()
{
return $this->capacity. ' Orang';
}
public function getTopSpeed()
{
return $this->topSpeed. ' Kmph';
}
}
class Motor extends AbstractShip
{
}
class Layar extends AbstractShip
{
protected $model = 'Layar';
protected $engine = 'Layar Kain';
protected $capacity = 20;
protected $topSpeed = 60;
}
class Pesiar extends AbstractShip
{
protected $model = 'Pesiar';
protected $capacity = 2000;
protected $topSpeed = 400;
}
function perahuku(AbstractShip $ship)
{
echo '---------------<br/>';
echo 'Nama Model : ' .$ship->getModel();
echo '<br/>';
echo 'Mesin : ' .$ship->getEngine();
echo '<br/>';
echo 'Kapasitas : ' .$ship->getCapacity();
echo '<br/>';
echo 'Kecepatan Maksimal : ' .$ship->getTopSpeed();
echo '<br/>';
}
$motor = new Motor();
perahuku($motor);
$layar = new Layar();
perahuku($layar);
$pesiar = new Pesiar();
perahuku($pesiar);
?>