forked from m9rco/algorithm-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKitchenQueue.php
More file actions
53 lines (48 loc) · 1.14 KB
/
KitchenQueue.php
File metadata and controls
53 lines (48 loc) · 1.14 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
<?php
/**
* KitchenQueue
* -------------------------------------------------------------
* [游戏说明]
* 假设你要为饭店创建一个接受顾客点菜单点应用程序,这个应用程序存储一系列点菜服务,服务员添加菜单,
* 而厨师取出菜单并制作菜肴
* -------------------------------------------------------------
*
* @author Pu ShaoWei <[email protected]>
* @date 2017/12/3
* @version 1.0
* @license MIT
*/
class KitchenQueue
{
/**
* @var \stdClass $cooking
*/
protected $cooking;
/**
* 服务员
*
* @param $dishes
*/
public function waiter($dishes)
{
$node = new \stdClass();
$node->element = $dishes;
$node->next = $this->cooking;
$this->cooking = $node;
}
/**
* 厨师
*
* @return \stdClass
*/
public function kitchen()
{
return $this->cooking;
}
}
$kitchen = new KitchenQueue();
$kitchen->waiter("Qin Jiao Rou Si");
$kitchen->waiter("Ma Po Dou Fu");
$kitchen->waiter("Fu Qi Fei Pian");
$kitchen->waiter("Kou Shui Ji");
var_dump($kitchen->kichen());