public void removeWorkers() {
   if (host != null && host.isWorking == false) {
     host.stopThread();
     host = null;
     numWorkers--;
   }
   if (cook != null && cook.isWorking == false) {
     cook.stopThread();
     cook = null;
     numWorkers--;
   }
   if (cashier != null && cashier.isWorking == false) {
     cashier.stopThread();
     cashier = null;
     numWorkers--;
   }
   synchronized (waiters) {
     for (WaiterAgent w : waiters) {
       if (w.isWorking == false) {
         w.stopThread();
         waiters.remove(w);
         numWorkers--;
       }
     }
   }
 }
 @Override
 public void endOfShift() {
   System.out.println("RESTAURANT RANCHO GOT END OF SHIFT");
   double wage;
   if (cashier != null) {
     wage = cashier.balance - 500;
     cashier.subtract(wage);
   } else wage = 0;
   if (wage != 0) {
     wage = wage / numWorkers;
   }
   System.out.println("WAGE IS " + wage + " NUM WORKERS IS " + numWorkers);
   isOpen = false;
   if (host != null) {
     host.msgShiftDone(wage);
     if (waiters.size() == 0) {
       if (cook != null) {
         cook.msgShiftDone(wage);
       }
       if (cashier != null) {
         cashier.msgShiftDone(wage);
       }
     }
   } else {
     if (cashier != null) {
       cashier.msgShiftDone(wage);
     }
     for (int i = 0; i < waiters.size(); i++) {
       WaiterAgent w = waiters.get(i);
       w.msgShiftDone(false, wage);
     }
     if (cook != null) {
       cook.msgShiftDone(wage);
     }
   }
 }
  public String[] getWorkers() {
    List<String> restWorkers = new ArrayList<String>();

    if (cashier != null) {
      String cashierName = "Cashier: " + cashier.getName();
      restWorkers.add(cashierName);
    }
    if (cook != null) {
      String cookName = "Cook: " + cook.getName();
      restWorkers.add(cookName);
    }
    if (host != null) {
      String hostName = "Host: " + host.getName();
      restWorkers.add(hostName);
    }
    for (WaiterAgent waiter : waiters) {
      String waiterName = "Waiter: " + waiter.getName();
      restWorkers.add(waiterName);
    }
    String[] workers = new String[restWorkers.size()];
    workers = restWorkers.toArray(workers);

    return workers;
  }
  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();
    }
  }