-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMotorcycleClass.php
More file actions
60 lines (38 loc) · 1.41 KB
/
MotorcycleClass.php
File metadata and controls
60 lines (38 loc) · 1.41 KB
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
<?php
class MotorcycleClass extends AbstractVehicle {
private $helmet;
private $helmetStatus = false;
private $longDistanceMinVal = 20;
public function setHelmet(HelmetClass $helmet) {
$this -> helmet = $helmet;
}
public function getHelmet() {
return $this -> helmet;
}
public function setHelmetStatus(bool $status) {
if ($this -> getHelmet() == null)
throw new Exception('Henüz takacak bir kask yok. Yola çıkamazsınız.');
$this -> helmetStatus = true;
}
public function getHelmetStatus() {
return $this -> helmetStatus;
}
public function checkMCRequirements(int $distance) {
if ($this -> helmet == null)
throw new InvalidArgumentException('Kask olmadan yola çıkamazsınız');
if ($this -> getHelmetStatus() == false)
throw new InvalidArgumentException('Yola çıkmadan önce kaskınızı takmalısınız');
if ($distance > $this -> longDistanceMinVal)
if ($this -> helmet -> getType() != 'longDistance')
throw new InvalidArgumentException('Bu kask ile uzun yola çıkamazsınız.');
return true;
}
public function run(int $distance) {
$this -> start();
$this -> testVehicleRequirements2Run($distance);
$this -> checkMCRequirements($distance);
echo 'Yola çıkıldı.<br>';
/// bu aşamada yolda bir takım kontroller yapılabilir, olası sorunlar (yağ sıcaklığı, arıza durumu vb.) kontrol edilebilir.
echo 'Varış noktasına ulaşıldı.<br>';
}
}