Exemplo n.º 1
0
  public void run() {
    Foodistan fdistan = Foodistan.getfoodistan();
    long waitTime = 0l;
    while (System.currentTimeMillis() <= Foodistan.getfoodistan().getFoodistanEndTime()) {
      for (int x = 0; x < fdistan.getFoodies().size(); x++) {
        Foodie f = fdistan.getFoodies().get(x);
        if (f.getfStatus() == foodieStatus.WAITING) {

          if ((fdistan.getMg().hasInventory(Foodistan.getfoodistan().getInv(), 1) == false)
              || (fdistan.getMg().calculateDiscount() < f.getFoodieDiscount())) {
          } else {
            waitTime = System.currentTimeMillis() - f.getWaitStartTime();
            if (waitTime > fdistan.getMaxWaitingTime()) fdistan.setMaxWaitingTime(waitTime);
            fdistan.setAvgWaitingTime(fdistan.getAvgWaitingTime() + waitTime);
            Item itm = fdistan.getMg().getItem(fdistan.getInv());
            fdistan.getFoodies().get(x).consumeItem(itm);
            fdistan.setAvgItemLifeTime(
                fdistan.getAvgItemLifeTime()
                    + (System.currentTimeMillis() - itm.getItemStartTime()));
            fdistan.getOdrsOnHold().remove(0).setOrdrStatus(orderStatus.COMPLETE);
            fdistan.getFoodiesOnHold().remove(0);
            fdistan.setBurgerNeeded(fdistan.getBurgerNeeded() - 1);
            fdistan.setOrdersDelivered(Foodistan.getfoodistan().getOrdersDelivered() + 1);
          }
        }
      }
    }
  }
Exemplo n.º 2
0
 public void run() {
   Foodistan fdistan = Foodistan.getfoodistan();
   while (System.currentTimeMillis() <= Foodistan.getfoodistan().getFoodistanEndTime()) {
     for (int k = 0; k < fdistan.getChefs().size(); k++) {
       Chef c = fdistan.chefs.get(k);
       if (((c.getcStatus() == chefStatus.BUSY)
           && (c.getCookStartTime() + (c.getCurrentCookTime())) < System.currentTimeMillis())) {
         Item itm = new Item(ItemType.BURGER);
         fdistan.getMg().refillInventory(itm);
         fdistan.chefs.get(k).setcStatus(chefStatus.SPEEDUPDATE);
         fdistan
             .chefs
             .get(k)
             .setCurrentCookTime(fdistan.chefs.get(k).getCurrentCookTime() * fdistan.getSpeedUp());
       }
     }
   }
 }