-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStore.java
More file actions
61 lines (46 loc) · 1.72 KB
/
Store.java
File metadata and controls
61 lines (46 loc) · 1.72 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
import java.util.ArrayList;
import java.util.List;
/**
* Created by psands on 1/26/2016
*/
public class Store {
public ArrayList<SaleItem> saleItems;
public ArrayList<AuctionItem> auctionItems;
public static void main(String[] args) {
Store myStore = new Store();
myStore.saleItems = new ArrayList<SaleItem>();
myStore.auctionItems = new ArrayList<AuctionItem>();
User u1 = new User("Anna");
User u2 = new User("Blake");
User u3 = new User("Caitlyn");
User u4 = new User("Dad");
myStore.saleItems.add(new SaleItem("Super fun stick", 2.50, u4, 0.1));
myStore.saleItems.add(new SaleItem("Volleyball", 22.49, u2, 0.2));
myStore.saleItems.add(new SaleItem("10,000-piece puzzle", 100.00, u3, 0.25));
myStore.auctionItems.add(new AuctionItem("Programming textbook", 10.00, u1, 10));
myStore.auctionItems.add(new AuctionItem("Cat pajamas", 9.25, u2, 8));
myStore.auctionItems.add(new AuctionItem("Bottlecap collection", 25.00, u3, 5));
myStore.auctionItems.add(new AuctionItem("Cup of joe", 1.99, u4, 5));
System.out.println(printItems(myStore.saleItems));
System.out.println(printItems(myStore.auctionItems));
advanceDay(myStore.auctionItems);
myStore.auctionItems.get(0).makeBid(u2, 11.00);
myStore.auctionItems.get(0).makeBid(u3, 11.00);
advanceDay(myStore.auctionItems);
myStore.saleItems.get(0).purchaseItem(u4);
System.out.println(printItems(myStore.saleItems));
System.out.println(printItems(myStore.auctionItems));
}
public static String printItems(List myList) {
String s = "Available items:\n";
for (Object i : myList) {
s += i + "\n";
}
return s;
}
public static void advanceDay(ArrayList<AuctionItem> myList) {
for (AuctionItem ai : myList) {
ai.advanceDay();
}
}
}