public void addPerson(Person p, String type, String name, double money) { removeWorkers(); if (!isOpen && type.equals("Customer")) { AlertLog.getInstance() .logMessage( AlertTag.RESTAURANT, name, " told to go home because Rancho de Zocalo is now closed"); p.msgDoneEating(false, money); return; } if (type.equals("Customer")) { // if ((p!=null) && returningCusts.containsKey(p)) { // returningCusts.get(p).getGui().setHungry(); // } // else { CustomerAgent c = new CustomerAgent(name, customers.size()); if (p != null) c.setPerson(p); // returningCusts.put(p, c); CustomerGui g = new CustomerGui(c, gui); g.setHungry(); c.setBalance(money); gui.cafeAniPanel.addGui(g); // dw if (host != null) c.setHost(host); if (cashier != null) c.setCashier(cashier); c.setGui(g); customers.add(c); c.startThread(); // } } else if (type.equals("Waiter")) { numWorkers++; WaiterAgentNorm w = new WaiterAgentNorm(name, this, menu, waiters.size() + 1); if (p != null) w.setPerson(p); WaiterGui g = new WaiterGui(w, gui); gui.cafeAniPanel.addGui(g); if (host != null) w.setHost(host); if (cashier != null) w.setCashier(cashier); if (host != null) host.addWaiter(w); if (cook != null) w.setCook(cook); waiters.add(w); w.setGui(g); w.startThread(); } else if (type.equals("WaiterPC")) { numWorkers++; WaiterAgentPC w = new WaiterAgentPC(name, this, menu, waiters.size() + 1); WaiterGui g = new WaiterGui(w, gui); if (p != null) w.setPerson(p); gui.cafeAniPanel.addGui(g); if (host != null) w.setHost(host); if (cook != null) w.setCook(cook); if (cashier != null) w.setCashier(cashier); if (host != null) host.addWaiter(w); w.setGui(g); waiters.add(w); w.startThread(); g.updatePosition(); } else if (type.equals("Host")) { numWorkers++; if (p != null && host != null) host.setPerson(p); host = new HostAgent(name); hostGui = new HostGui(host); host.setGui(hostGui); for (WaiterAgent w : waiters) { w.setHost(host); host.addWaiter(w); } for (CustomerAgent c : customers) { c.setHost(host); } host.startThread(); } else if (type.equals("Cook")) { numWorkers++; cook = new CookAgent(name, this, foods); if (p != null) cook.setPerson(p); CookGui cookGui = new CookGui(cook, gui); cook.setGui(cookGui); gui.cafeAniPanel.addGui(cookGui); for (WaiterAgent w : waiters) { w.setCook(cook); } /* for(int i = 0; i<3; i++){ MarketAgent market = new MarketAgent(i, menu, 5); market.setCashier(cashier); market.startThread(); cook.addMarket(market); }*/ cook.setMarket(market); cook.startThread(); AlertLog.getInstance().logInfo(AlertTag.RESTAURANT, "COOK", "COOK's thread started "); } else if (type.equals("Cashier")) { numWorkers++; cashier = new CashierAgent(name, menu); if (p != null) cashier.setPerson(p); CashierGui cashierGui = new CashierGui(cashier, gui); for (WaiterAgent w : waiters) { w.setCashier(cashier); } for (CustomerAgent c : customers) { c.setCashier(cashier); } cashier.setGui(cashierGui); cashier.setRestaurant(this); gui.cafeAniPanel.addGui(cashierGui); cashier.startThread(); } }