-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.php.txt
68 lines (55 loc) · 1.37 KB
/
menu.php.txt
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
<?php
class Menu {
protected $name;
protected $price;
protected $image;
private $orderCount = 0;
protected static $count = 0;
public function __construct($name, $price, $image) {
$this->name = $name;
$this->price = $price;
$this->image = $image;
self::$count++;
}
public function hello() {
echo 'I am '.$this->name;
}
public function getName() {
return $this->name;
}
public function getImage() {
return $this->image;
}
public function getOrderCount() {
return $this->orderCount;
}
public function setOrderCount($orderCount) {
$this->orderCount = $orderCount;
}
public function getTaxIncludedPrice() {
return round($this->price * 1.0725, 2);
}
public function getTotalPrice() {
return $this->getTaxIncludedPrice() * $this->orderCount;
}
public function getReviews($reviews) {
$reviewsForMenu = array();
foreach ($reviews as $review) {
if ($review->getMenuName() == $this->name) {
$reviewsForMenu[] = $review;
}
}
return $reviewsForMenu;
}
public static function getCount() {
return self::$count;
}
public static function findByName($menus, $name) {
foreach ($menus as $menu) {
if ($menu->getName() == $name) {
return $menu;
}
}
}
}
?>