1 import java.util.*;
2
3 /**
4
5 */
6 public class Bundle implements LineItem
7 {
8 /**
9
10 */
11 public Bundle() { items = new ArrayList<>(); }
12
13 /**
14
15 @param item
16 */
17 public void add(LineItem item) { items.add(item); }
18
19 public double getPrice()
20 {
21 double price = 0;
22
23 for (LineItem item : items)
24 price += item.getPrice();
25 return price;
26 }
27
28 public String toString()
29 {
30 String description = "Bundle: ";
31 for (int i = 0; i < items.size(); i++)
32 {
33 if (i > 0) description += ", ";
34 description += items.get(i).toString();
35 }
36 return description;
37 }
38
39 private ArrayList<LineItem> items;
40 }