Ejemplo n.º 1
0
  /**
   * BasketCart의 HashMap에 basket객체를 삭제해준다. ProductID를 키로 하여 존재 유무를 확인하고 존재할때 quantity의 수를 감소 시킨다.
   *
   * @param String productID
   */
  public void remove(String productID) {
    if (items.containsKey(productID)) {
      Basket basket = items.get(productID);
      // System.out.println("삭제전 :" + basket.getQuantity() + " " + basket.getTotalPrice());
      basket.decrementQuantity();
      // System.out.println("삭제후 :" + basket.getQuantity() + " " + basket.getTotalPrice());

      if (basket.getQuantity() <= 0) {
        items.remove(productID);
        numberOfItems--;
      }
    }
  }