Пример #1
0
  /**
   * @param coin
   * @return
   * @throws VendingMachineException
   *     <p>Return true if the coin param is accepted after validated with some rules
   */
  public boolean validateChange(Coin coin) {
    if (!coin.getClass().getName().equals(Coin10JPY.class.getName())) {
      List<Coin> coins = this.getCoinGroup().get(Coin10JPY.class.getName());
      if (coins.size() < 1) {
        System.out.println(
            "Machine cannot accept "
                + coin.getValue()
                + "JPY because we don't have channge for it. Please use 10JPY coin money");
        this.getVendingMachine().operate();
      }
    }

    return false;
  }