public TableGUI(int id, Tables tables) { this.tables = tables; this.id = id; tables.addObserver(this); setTitle("Table " + id); items = new ArrayList<Order>(); initialize(); }
@Override /** update function */ public void update() { if (tables.get(id) != null) { // check and add order that has not yet in table // but delivered to this table for (Order order : tables.get(id)) { Iterator<Order> it = items.iterator(); Order item = null; boolean found = false; while (!found && it.hasNext()) { item = it.next(); if (order.getOrderId() == item.getOrderId()) { found = true; } } if (!found) { items.add(order); textOrders.append(order.toString() + "\n"); } } // end for } // end if }