1 package demo.data; 2 3 import java.util.ArrayList ; 4 5 public class Order 6 { 7 private int id; 8 private ArrayList items; 9 10 public Order (int aId) { 11 id = aId; 12 items = new ArrayList (); 13 } 14 15 public int getId() { 16 return id; 17 } 18 19 public void addItem (Item aItem) { 20 items.add(aItem); 21 } 22 23 public Item[] getItems() { 24 Object objs[] = items.toArray(); 25 Item items[] = new Item[objs.length]; 26 System.arraycopy(objs, 0, items, 0, items.length); 27 return items; 28 } 29 } 30 31 | Popular Tags |