-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auction.php
108 lines (91 loc) · 1.51 KB
/
Auction.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
include_once 'AuctionStatus.php';
include_once 'AuctionType.php';
include_once 'Bid.php';
class Auction {
/**
* @var string
*/
private $name;
/**
* @var AuctionType
*/
private $type;
/**
* @var AuctionStatus
*/
private $status;
/**
* @var int
*/
private $startPrice;
/**
* @var int
*/
private $buyNowPrice;
/**
* @var Bid[]
*/
private $bids;
/**
* @param string $name
* @param AuctionType $type
* @param AuctionStatus $status
* @param int $startPrice
* @param int $buyNowPrice
*/
public function __construct($name, $type, $status, $startPrice, $buyNowPrice) {
$this->name = $name;
$this->type = $type;
$this->status = $status;
if (AuctionType::BID == $type) {
$this->startPrice = $startPrice;
$this->bids = array();
}
if (AuctionType::BUY_NOW == $type) {
$this->buyNowPrice = $buyNowPrice;
}
}
/**
* @param int $price
*/
public function addBid($price) {
$this->bids[] = new Bid($price);
}
/**
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return AuctionType
*/
public function getType() {
return $this->type;
}
/**
* @return AuctionStatus
*/
public function getStatus() {
return $this->status;
}
/**
* @return int
*/
public function getStartPrice() {
return $this->startPrice;
}
/**
* @return int
*/
public function getBuyNowPrice() {
return $this->buyNowPrice;
}
/**
* @return Bid[]
*/
public function getBids() {
return $this->bids;
}
}