Exemple #1
0
 public void syncPanel() {
   panelPat.syncPanel();
   regionAButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.A);
   regionBButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.B);
   regionCButton.setBorderPainted(dlg.panelMain.mark.getRegion() == Reg.C);
   elevBox.setText(dlg.panelMain.mark.getElevation());
   heightBox.setText(dlg.panelMain.mark.getObjectHeight());
   sourceBox.setText(dlg.panelMain.mark.getSource());
   infoBox.setText(dlg.panelMain.mark.getInfo());
   for (Sts sts : statuses.keySet()) {
     int item = statuses.get(sts);
     if (dlg.panelMain.mark.getStatus() == sts) statusBox.setSelectedIndex(item);
   }
   for (Cns cns : constructions.keySet()) {
     int item = constructions.get(cns);
     if (dlg.panelMain.mark.getConstr() == cns) constrBox.setSelectedIndex(item);
   }
   for (Con con : conspicuities.keySet()) {
     int item = conspicuities.get(con);
     if (dlg.panelMain.mark.getConsp() == con) conBox.setSelectedIndex(item);
   }
   for (Con con : reflectivities.keySet()) {
     int item = reflectivities.get(con);
     if (dlg.panelMain.mark.getRefl() == con) reflBox.setSelectedIndex(item);
   }
 }
Exemple #2
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   if ((dlg.panelMain.mark.getObject() != Obj.MORFAC)
       || (dlg.panelMain.mark.getCategory() == Cat.MOR_BUOY)) {
     for (Shp shp : shapes.keySet()) {
       JRadioButton button = shapes.get(shp);
       if (button.isSelected()) {
         dlg.panelMain.mark.setShape(shp);
         if (SeaMark.EntMAP.get(dlg.panelMain.mark.getObject()) != Ent.MOORING) {
           dlg.panelMain.mark.setObject(objects.get(shp));
           if (dlg.panelMain.mark.getObjColour(0) == Col.UNKCOL) {
             dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
             dlg.panelMain.mark.setObjColour(Col.YELLOW);
           }
           if (button == cairnButton) {
             dlg.panelMain.mark.setObjPattern(Pat.NOPAT);
             dlg.panelMain.mark.setObjColour(Col.UNKCOL);
           }
           topmarkButton.setVisible(dlg.panelMain.mark.testValid());
         }
         button.setBorderPainted(true);
       } else button.setBorderPainted(false);
     }
     dlg.panelMain.panelMore.syncPanel();
   }
 }
Exemple #3
0
 public synchronized void decreaseStock(Book book, int quantity, int jobSeqNum)
     throws InterruptedException {
   while (!inventory.containsKey(book) || inventory.get(book).intValue() < quantity) {
     wait();
   }
   inventory.put(book, inventory.get(book) - quantity);
   printWork(false, jobSeqNum, book, inventory.get(book) + quantity, inventory.get(book));
 }
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Shp shp : shapes.keySet()) {
     JRadioButton button = shapes.get(shp);
     if (button.isSelected()) {
       SmedAction.panelMain.mark.setShape(shp);
       SmedAction.panelMain.mark.setObject(objects.get(shp));
       button.setBorderPainted(true);
     } else button.setBorderPainted(false);
   }
   if (SmedAction.panelMain.mark.testValid()) {
     SmedAction.panelMain.panelChan.topmarkButton.setVisible(true);
     SmedAction.panelMain.panelChan.lightButton.setVisible(true);
     if (SmedAction.panelMain.mark.getCategory() == Cat.LAM_STBD) {
       switch (SmedAction.panelMain.mark.getRegion()) {
         case A:
           SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
           SmedAction.panelMain.mark.setObjColour(Col.GREEN);
           break;
         case B:
           SmedAction.panelMain.mark.setObjPattern(Pat.NOPAT);
           SmedAction.panelMain.mark.setObjColour(Col.RED);
           break;
         case C:
           SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
           SmedAction.panelMain.mark.setObjColour(Col.GREEN);
           SmedAction.panelMain.mark.addObjColour(Col.WHITE);
           SmedAction.panelMain.mark.addObjColour(Col.GREEN);
           SmedAction.panelMain.mark.addObjColour(Col.WHITE);
           break;
       }
     } else {
       SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP);
       switch (SmedAction.panelMain.mark.getRegion()) {
         case A:
           SmedAction.panelMain.mark.setObjColour(Col.GREEN);
           SmedAction.panelMain.mark.addObjColour(Col.RED);
           SmedAction.panelMain.mark.addObjColour(Col.GREEN);
           break;
         case B:
           SmedAction.panelMain.mark.setObjColour(Col.RED);
           SmedAction.panelMain.mark.addObjColour(Col.GREEN);
           SmedAction.panelMain.mark.addObjColour(Col.RED);
           break;
         case C:
           SmedAction.panelMain.mark.setObjColour(Col.RED);
           SmedAction.panelMain.mark.addObjColour(Col.GREEN);
           SmedAction.panelMain.mark.addObjColour(Col.RED);
           SmedAction.panelMain.mark.addObjColour(Col.GREEN);
           break;
       }
     }
     SmedAction.panelMain.panelMore.syncPanel();
   } else {
     SmedAction.panelMain.panelChan.topmarkButton.setVisible(false);
     SmedAction.panelMain.panelChan.lightButton.setVisible(false);
   }
 }
Exemple #5
0
    private Node(
        AbstractAction prevAct,
        ActionState state,
        Round prevRound,
        List<AbstractAction> path,
        PathToFlop pathToFlop) {
      if (pathToFlop != null) {
        PATH = pathToFlop;
      } else {
        if (prevAct != null) {
          path.add(prevAct);
        }
        PATH = PathToFlop.matching(path);
      }

      // nextIntent

      INDEX = nextIndex++;
      ID = nextId(PATH, state.round());
      INTENT = nextIntent(prevRound);
      CAN_RAISE = state.canRaise();
      CAN_CHECK = state.canCheck();
      STATUS = state.headsUpStatus();
      ROUND = state.round();
      STAKES = state.stakes().smallBlinds();
      DEALER_COMMIT = state.seat(1).commitment().smallBlinds();
      DEALEE_COMMIT = state.seat(0).commitment().smallBlinds();
      DEALER_NEXT = state.dealerIsNext();
      STATE = state;

      KIDS = new EnumMap<>(AbstractAction.class);
      for (Map.Entry<AbstractAction, ActionState> act : state.actions(false).entrySet())
      //                    state.viableActions().entrySet())
      {
        List<AbstractAction> nextPath = (PATH == null) ? new ArrayList<>(path) : null;

        //                if (! act.getValue().atEndOfHand()) {
        KIDS.put(act.getKey(), new Node(act.getKey(), act.getValue(), ROUND, nextPath, PATH));
        //                }
      }

      // intents
      F_INTENT = intent(AbstractAction.QUIT_FOLD);
      C_INTENT = intent(AbstractAction.CHECK_CALL);
      R_INTENT = intent(AbstractAction.BET_RAISE);

      KID_NODES =
          new Node[] {
            KIDS.get(AbstractAction.QUIT_FOLD),
            KIDS.get(AbstractAction.CHECK_CALL),
            KIDS.get(AbstractAction.BET_RAISE)
          };
    }
Exemple #6
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Cat cat : categories.keySet()) {
     int idx = categories.get(cat);
     if (dlg.node != null && (idx == categoryBox.getSelectedIndex()))
       dlg.panelMain.mark.setCategory(cat);
   }
 }
Exemple #7
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Sts sts : statuses.keySet()) {
     int idx = statuses.get(sts);
     if (dlg.panelMain.mark != null && (idx == statusBox.getSelectedIndex()))
       dlg.panelMain.mark.setStatus(sts);
   }
 }
Exemple #8
0
 public static void main(String[] args) {
   EnumMap<AlarmPoints, Command> em = new EnumMap<AlarmPoints, Command>(AlarmPoints.class);
   em.put(
       KITCHEN,
       new Command() {
         public void action() {
           print("Kitchen fire!");
         }
       });
   em.put(
       BATHROOM,
       new Command() {
         public void action() {
           print("Bathroom alert!");
         }
       });
   for (Map.Entry<AlarmPoints, Command> e : em.entrySet()) {
     printnb(e.getKey() + ": ");
     e.getValue().action();
   }
   try { // If there's no value for a particular key:
     em.get(UTILITY).action();
   } catch (Exception e) {
     print(e);
   }
 }
Exemple #9
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Cns cns : constructions.keySet()) {
     int idx = constructions.get(cns);
     if (dlg.panelMain.mark != null && (idx == constrBox.getSelectedIndex()))
       dlg.panelMain.mark.setConstr(cns);
   }
 }
  @Override
  @Transactional
  public LocalizationResponse localize(MeasurementContainer container) {
    User user = userRepository.findByUsername(container.getUsername());
    List<Fingerprint> userPrints = container.getFingerprints();
    // We sort the prints to make matching easier
    Collections.sort(userPrints);
    List<Place> places = placeRepository.findAll();

    // If there are no places we won't do anything
    if (places.isEmpty()) {
      return new LocalizationResponse();
    }

    Place leastErraneousPlace =
        localizationAlgorithms.get(container.getType()).localize(places, userPrints);

    cutDownHistoryOccurrencesTo9(user.getHistory());

    saveAsHistoryOccurrence(leastErraneousPlace, user);

    LocalizationResponse response = new LocalizationResponse();
    response.setPlaceName(leastErraneousPlace.getName());
    response.setAuthenticationSuccessful(true);
    return response;
  }
Exemple #11
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Con con : reflectivities.keySet()) {
     int idx = reflectivities.get(con);
     if (dlg.panelMain.mark != null && (idx == reflBox.getSelectedIndex()))
       dlg.panelMain.mark.setRefl(con);
   }
 }
  public AttributeFilter getAttributeFilter(Entity entity) {
    AttributeFilter filter = attributeFilters.get(entity);
    if (filter == null)
      throw new IllegalArgumentException("No Attribute Filter for " + entity + " configured");

    return filter;
  }
  public IDGenerator getIDGenerator(IDGenerator.Name name) {
    IDGenerator filter = idGenerators.get(name);
    if (filter == null)
      throw new IllegalArgumentException("No ID Generator for " + name + " configured");

    return filter;
  }
 public void syncPanel() {
   for (Shp shp : shapes.keySet()) {
     JRadioButton button = shapes.get(shp);
     if (SmedAction.panelMain.mark.getShape() == shp) {
       button.setBorderPainted(true);
     } else button.setBorderPainted(false);
   }
 }
 protected void initNodesLoader() {
   if (!isUseNodes) {
     isUseNodes =
         shaderNames.get(Shader.ShaderType.Vertex) == null
             && shaderNames.get(Shader.ShaderType.Fragment) == null;
     if (isUseNodes) {
       if (nodesLoaderDelegate == null) {
         nodesLoaderDelegate = new ShaderNodeLoaderDelegate();
       } else {
         nodesLoaderDelegate.clear();
       }
       nodesLoaderDelegate.setTechniqueDef(technique);
       nodesLoaderDelegate.setMaterialDef(materialDef);
       nodesLoaderDelegate.setAssetManager(assetManager);
     }
   }
 }
Exemple #16
0
 public void syncPanel() {
   if (SeaMark.EntMAP.get(dlg.panelMain.mark.getObject()) == Ent.MOORING) {
     mooringButton.setBorderPainted(true);
     categoryBox.setVisible(false);
     mooringBox.setVisible(true);
     pillarButton.setEnabled(false);
     sparButton.setEnabled(false);
     beaconButton.setEnabled(false);
     towerButton.setEnabled(false);
     stakeButton.setEnabled(false);
     cairnButton.setEnabled(false);
     noticeButton.setEnabled(false);
     topmarkButton.setVisible(false);
     for (Cat cat : moorings.keySet()) {
       int item = moorings.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) mooringBox.setSelectedIndex(item);
     }
   } else {
     mooringButton.setBorderPainted(false);
     mooringBox.setVisible(false);
     categoryBox.setVisible(true);
     pillarButton.setEnabled(true);
     sparButton.setEnabled(true);
     beaconButton.setEnabled(true);
     towerButton.setEnabled(true);
     stakeButton.setEnabled(true);
     cairnButton.setEnabled(true);
     noticeButton.setEnabled(true);
     topmarkButton.setBorderPainted(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setSelected(dlg.panelMain.mark.getTopmark() != Top.NOTOP);
     topmarkButton.setVisible(dlg.panelMain.mark.testValid());
     for (Cat cat : categories.keySet()) {
       int item = categories.get(cat);
       if (dlg.panelMain.mark.getCategory() == cat) categoryBox.setSelectedIndex(item);
     }
   }
   for (Shp shp : shapes.keySet()) {
     JRadioButton button = shapes.get(shp);
     if (dlg.panelMain.mark.getShape() == shp) {
       button.setBorderPainted(true);
     } else button.setBorderPainted(false);
   }
   noticeButton.setBorderPainted(false);
   dlg.panelMain.mark.testValid();
 }
Exemple #17
0
  @Override
  public TerminalSize getPreferredSize(List<Component> components) {
    EnumMap<Location, Component> layout = makeLookupMap(components);
    int preferredHeight =
        (layout.containsKey(Location.TOP)
                ? layout.get(Location.TOP).getPreferredSize().getRows()
                : 0)
            + Math.max(
                layout.containsKey(Location.LEFT)
                    ? layout.get(Location.LEFT).getPreferredSize().getRows()
                    : 0,
                Math.max(
                    layout.containsKey(Location.CENTER)
                        ? layout.get(Location.CENTER).getPreferredSize().getRows()
                        : 0,
                    layout.containsKey(Location.RIGHT)
                        ? layout.get(Location.RIGHT).getPreferredSize().getRows()
                        : 0))
            + (layout.containsKey(Location.BOTTOM)
                ? layout.get(Location.BOTTOM).getPreferredSize().getRows()
                : 0);

    int preferredWidth =
        Math.max(
            (layout.containsKey(Location.LEFT)
                    ? layout.get(Location.LEFT).getPreferredSize().getColumns()
                    : 0)
                + (layout.containsKey(Location.CENTER)
                    ? layout.get(Location.CENTER).getPreferredSize().getColumns()
                    : 0)
                + (layout.containsKey(Location.RIGHT)
                    ? layout.get(Location.RIGHT).getPreferredSize().getColumns()
                    : 0),
            Math.max(
                layout.containsKey(Location.TOP)
                    ? layout.get(Location.TOP).getPreferredSize().getColumns()
                    : 0,
                layout.containsKey(Location.BOTTOM)
                    ? layout.get(Location.BOTTOM).getPreferredSize().getColumns()
                    : 0));
    return new TerminalSize(preferredWidth, preferredHeight);
  }
  public void testEnumMap() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    String JSON = "{ \"KEY1\" : \"\", \"WHATEVER\" : null }";

    // to get typing, must use type reference
    EnumMap<Key, String> result =
        mapper.readValue(JSON, new TypeReference<EnumMap<Key, String>>() {});

    assertNotNull(result);
    assertEquals(EnumMap.class, result.getClass());
    assertEquals(2, result.size());

    assertEquals("", result.get(Key.KEY1));
    // null should be ok too...
    assertTrue(result.containsKey(Key.WHATEVER));
    assertNull(result.get(Key.WHATEVER));

    // plus we have nothing for this key
    assertFalse(result.containsKey(Key.KEY2));
    assertNull(result.get(Key.KEY2));
  }
Exemple #19
0
 public void actionPerformed(java.awt.event.ActionEvent e) {
   for (Cat cat : moorings.keySet()) {
     int idx = moorings.get(cat);
     if (dlg.node != null && (idx == mooringBox.getSelectedIndex())) {
       dlg.panelMain.mark.setCategory(cat);
       if ((cat == Cat.INB_CALM) || (cat == Cat.INB_SBM)) {
         dlg.panelMain.mark.setObject(Obj.BOYINB);
         dlg.panelMain.mark.setShape(Shp.UNKSHP);
       } else {
         dlg.panelMain.mark.setObject(Obj.MORFAC);
         if (cat != Cat.MOR_BUOY) dlg.panelMain.mark.setShape(Shp.UNKSHP);
       }
     }
   }
   if (dlg.node != null) syncPanel();
 }
  /**
   * Localizes user by selected localization measure by selecting a proper localization command
   * object and adding closest place to user's history
   *
   * @param username Username of user to be localized
   * @param measurementform Measurement form containing user's Fingerprint data and selected
   *     localization measure
   */
  @Override
  @Transactional
  public void localize(String username, MeasurementForm measurementform) {
    User user = userRepository.findByUsername(username);
    ArrayList<Fingerprint> userPrints = measurementform.makeFingerprints();
    // We sort the prints to make matching easier
    Collections.sort(userPrints);
    List<Place> places = placeRepository.findAll();

    // If there are no places we won't do anything
    if (places.isEmpty()) {
      return;
    }

    Place leastErraneousPlace =
        localizationAlgorithms.get(measurementform.getType()).localize(places, userPrints);

    cutDownHistoryOccurrencesTo9(user.getHistory());

    saveAsHistoryOccurrence(leastErraneousPlace, user);
  }
Exemple #21
0
 /** Create Tag Field using generic key */
 public TagField createField(FieldKey genericKey, String value) {
   return new ID3v1TagField(tagFieldToID3v1Field.get(genericKey).name(), value);
 }
Exemple #22
0
  @Override
  public void doLayout(TerminalSize area, List<Component> components) {
    EnumMap<Location, Component> layout = makeLookupMap(components);
    int availableHorizontalSpace = area.getColumns();
    int availableVerticalSpace = area.getRows();

    // We'll need this later on
    int topComponentHeight = 0;
    int leftComponentWidth = 0;

    // First allocate the top
    if (layout.containsKey(Location.TOP)) {
      Component topComponent = layout.get(Location.TOP);
      topComponentHeight =
          Math.min(topComponent.getPreferredSize().getRows(), availableVerticalSpace);
      topComponent.setPosition(TerminalPosition.TOP_LEFT_CORNER);
      topComponent.setSize(new TerminalSize(availableHorizontalSpace, topComponentHeight));
      availableVerticalSpace -= topComponentHeight;
    }

    // Next allocate the bottom
    if (layout.containsKey(Location.BOTTOM)) {
      Component bottomComponent = layout.get(Location.BOTTOM);
      int bottomComponentHeight =
          Math.min(bottomComponent.getPreferredSize().getRows(), availableVerticalSpace);
      bottomComponent.setPosition(new TerminalPosition(0, area.getRows() - bottomComponentHeight));
      bottomComponent.setSize(new TerminalSize(availableHorizontalSpace, bottomComponentHeight));
      availableVerticalSpace -= bottomComponentHeight;
    }

    // Now divide the remaining space between LEFT, CENTER and RIGHT
    if (layout.containsKey(Location.LEFT)) {
      Component leftComponent = layout.get(Location.LEFT);
      leftComponentWidth =
          Math.min(leftComponent.getPreferredSize().getColumns(), availableHorizontalSpace);
      leftComponent.setPosition(new TerminalPosition(0, topComponentHeight));
      leftComponent.setSize(new TerminalSize(leftComponentWidth, availableVerticalSpace));
      availableHorizontalSpace -= leftComponentWidth;
    }
    if (layout.containsKey(Location.RIGHT)) {
      Component rightComponent = layout.get(Location.RIGHT);
      int rightComponentWidth =
          Math.min(rightComponent.getPreferredSize().getColumns(), availableHorizontalSpace);
      rightComponent.setPosition(
          new TerminalPosition(area.getColumns() - rightComponentWidth, topComponentHeight));
      rightComponent.setSize(new TerminalSize(rightComponentWidth, availableVerticalSpace));
      availableHorizontalSpace -= rightComponentWidth;
    }
    if (layout.containsKey(Location.CENTER)) {
      Component centerComponent = layout.get(Location.CENTER);
      centerComponent.setPosition(new TerminalPosition(leftComponentWidth, topComponentHeight));
      centerComponent.setSize(new TerminalSize(availableHorizontalSpace, availableVerticalSpace));
    }

    // Set the remaining components to 0x0
    for (Component component : components) {
      if (!layout.values().contains(component)) {
        component.setPosition(TerminalPosition.TOP_LEFT_CORNER);
        component.setSize(TerminalSize.ZERO);
      }
    }
  }
Exemple #23
0
 private int intent(AbstractAction forAction) {
   return !KIDS.containsKey(forAction) ? -1 : KIDS.get(forAction).intent();
 }
Exemple #24
0
 String get(Field field) {
   return entries.get(field);
 }
Exemple #25
0
 State getTransition(JsonToken token, State enclosingState) {
   return transitions.get(token);
 }
Exemple #26
0
 public synchronized void increaseStock(Book book, int quantity, int jobSeqNum) {
   if (inventory.containsKey(book)) inventory.put(book, inventory.get(book) + quantity);
   else inventory.put(book, quantity);
   printWork(true, jobSeqNum, book, inventory.get(book) - quantity, inventory.get(book));
   notifyAll();
 }
  /**
   * Programa principal para o projeto 2.
   *
   * @param args argumentos da linha de comando.
   */
  public static void main(String[] args) {
    // Faz o parsing dos argumentos da linha de comando.
    GetOpt options = new GetOpt("Projeto2", args, "vr");
    int opt;
    while ((opt = options.nextOpt()) != -1) {
      switch (opt) {
        default:
          usage();
          break;
        case 'v':
          verbose = true;
          break;
        case 'r':
          rand = new Random(0);
          break;
      }
    }
    if (rand == null) {
      rand = new Random();
    }
    if (options.optind != args.length - 2) {
      usage();
    }
    alambiqueCount = Integer.parseInt(args[options.optind]);
    int iteracoes = Integer.parseInt(args[options.optind + 1]);

    // Cria os atravessadores
    atravessadores = new EnumMap<Cana, Atravessador>(Cana.class);
    for (Cana g : Cana.values()) {

      // Voc� precisa implementar a classe AtravessadorImpl para o programa funcionar.
      atravessadores.put(g, new AtravessadorImpl(g));
    }

    // Criar o �nico fornecedor.
    fornecedor = new Fornecedor(iteracoes);

    Thread threadFornecedor = new Thread(fornecedor, "Fornecedor");

    alambiques = new Alambique[alambiqueCount];
    alambiqueThreads = new Thread[alambiqueCount];
    for (int i = 0; i < alambiqueCount; i++) {
      alambiques[i] = new Alambique();
      alambiqueThreads[i] = new Thread(alambiques[i], "Alambique " + i);
    }

    // Inicia os threads
    // Todos eles tem prioridade mais baixa que o thread pricniapl ent�o nenhum deles
    // come�ar� a rodar antes que todos tenham sidos inicializados.
    threadFornecedor.setPriority(Thread.NORM_PRIORITY - 1);
    threadFornecedor.start();
    for (Thread t : alambiqueThreads) {
      t.setPriority(Thread.NORM_PRIORITY - 1);
      t.start();
    }

    // Espera que todos os threads sejam finalizados
    try {
      // O thread do fornecedor ser� finalizado quando ele concluir todas as itera��es
      // especificadas.
      threadFornecedor.join();

      // Espera 3 segundos para dar uma chance para os threads do alambique terminarem
      // depois disso, todos que n�o finalizarem ser�o interrompidos.
      Thread.sleep(3000);

      for (Thread t : alambiqueThreads) {
        t.interrupt();
        t.join();
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    // imprime o estado final
    out.printf("**** Finalizando%n");

    Pedido quant;
    Pedido balanco = new Pedido();
    int produzido = 0;
    int nosAtravessadores = 0;
    int consumido = 0;

    quant = fornecedor.getProducao();
    out.printf("Produzido %s%n", quant);

    for (Cana g : Cana.values()) {
      int n = quant.get(g);
      balanco.troca(g, n);
      produzido += n;
    }

    for (Cana g : Cana.values()) {
      quant = atravessadores.get(g).getEstoqueDisponivel();
      for (Cana c1 : Cana.values()) {
        int n = quant.get(c1);
        balanco.troca(c1, -n);
        nosAtravessadores += n;
      }
    }

    for (int i = 0; i < alambiqueCount; i++) {
      quant = alambiques[i].getConsumo();
      out.printf("O Alambique %d consumiu %s%n", i, quant);
      for (Cana g : Cana.values()) {
        int n = quant.get(g);
        balanco.troca(g, -n);
        consumido += n;
      }
    }
    out.printf("O balan�o final � %s%n", balanco);
    out.printf(
        "Total: produzido = %d, consumido = %d,"
            + " sobrando nos atravessadores = %d, liquido = %d%n",
        produzido, consumido, nosAtravessadores, (produzido - consumido - nosAtravessadores));
  } // main(String[])
 /**
  * Retorna o atravessador especialista em uma determinada variedade de cana de a��car
  *
  * @param g a variedade de cana
  * @return o atravessador especialista na variedade de cana de a��car g
  */
 public static Atravessador especialista(Cana g) {
   return atravessadores.get(g);
 }