-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuctionItem.java
More file actions
123 lines (102 loc) · 3.08 KB
/
Copy pathAuctionItem.java
File metadata and controls
123 lines (102 loc) · 3.08 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import java.io.Serializable;
public class AuctionItem implements Serializable {
private int itemId;
private int startingPrice;
private String itemTitle;
private String itemDescription;
private int highestBid;
private Buyer currentBuyer;
private int minPrice;
private Seller seller;
private boolean closed;
public AuctionItem(Seller seller, int itemId, int startingPrice, int minPrice, String itemTitle, String itemDescription) {
this.itemId = itemId;
this.startingPrice = startingPrice;
this.itemTitle = itemTitle;
this.itemDescription = itemDescription;
highestBid = startingPrice;
currentBuyer = null;
this.minPrice = minPrice;
this.seller = seller;
closed = false;
}
public void setClosed(boolean closed) {
this.closed = closed;
}
public boolean isClosed() {
return closed;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("\n");
sb.append("Information about item with ID " + itemId + ": ");
sb.append("\n");
sb.append("Title: " + itemTitle);
sb.append("\n");
sb.append("Description: " + itemDescription);
sb.append("\n");
sb.append("Starting price: " + startingPrice);
sb.append("\n");
sb.append("Seller: " + seller.getEmail());
sb.append("\n");
if (currentBuyer != null) {
sb.append("Highest bid: " + highestBid);
sb.append("\n");
sb.append("Current buyer: " + currentBuyer.getEmail());
sb.append("\n");
}
else {
sb.append("Status: No buyer have bidded or beaten the minimum price for this item.");
sb.append("\n");
}
return sb.toString();
}
public void setItemId(int itemId) {
this.itemId = itemId;
}
public void setStartingPrice(int startingPrice) {
this.startingPrice = startingPrice;
}
public void setItemTitle(String itemTitle) {
this.itemTitle = itemTitle;
}
public void setItemDescription(String itemDescription) {
this.itemDescription = itemDescription;
}
public void setHighestBid(int highestBid) {
this.highestBid = highestBid;
}
public void setNewBuyer(Buyer newBuyer) {
currentBuyer = newBuyer;
}
public void setMinPrice(int minPrice) {
this.minPrice = minPrice;
}
public int getItemId() {
return itemId;
}
public int getStartingPrice() {
return startingPrice;
}
public String getItemTitle() {
return itemTitle;
}
public String getItemDescription() {
return itemDescription;
}
public int getHighestBid() {
return highestBid;
}
public Buyer getCurrentBuyer() {
return currentBuyer;
}
public int getMinPrice() {
return minPrice;
}
@Override
public boolean equals(Object o) {
AuctionItem ai = (AuctionItem) o;
return itemId == ai.getItemId();
}
}