-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathBag.php
62 lines (54 loc) · 1 KB
/
Bag.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
<?php
namespace DesignPatterns\Behavioral\MediatorPattern;
/**
* Class Bag.
*/
class Bag extends Colleague
{
/**
* @var Bells
*/
protected $bells;
/**
* @var Turnips
*/
protected $turnips;
/**
* Bag constructor.
*/
public function __construct()
{
$this->bells = new Bells(0);
$this->turnips = new Turnips(0);
}
/**
* @return int
*/
public function getBells(): int
{
return $this->bells->getBells();
}
/**
* @return int
*/
public function getTurnips(): int
{
return $this->turnips->getCount();
}
/**
* @param int $bells
*/
public function setBells(int $bells)
{
echo "[背包] 剩下 $bells 鈴錢。";
$this->bells->setBells($bells);
}
/**
* @param int $count
*/
public function setTurnips(int $count)
{
echo "[背包] 剩下 $count 顆大頭菜。";
$this->turnips->setCount($count);
}
}