示例#1
0
 public int getTotalPrice() {
   int totalPrice = 0;
   Collection<Basket> collection = items.values();
   Iterator<Basket> iterator = collection.iterator();
   Basket basket;
   while (iterator.hasNext()) {
     basket = iterator.next();
     totalPrice = totalPrice + basket.getTotalPrice();
   }
   return totalPrice;
 }
示例#2
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--;
      }
    }
  }
示例#3
0
 /**
  * BasketCart의 HashMap에 basket객체를 더해 준다. ProductID를 키로 하여 존재를 유무를 확인하고 존재할 때 quantity의 수를
  * parameter로 받아 증가 시킨다.
  *
  * @param String productID,Basket basket,int quantity
  */
 public void add(String productID, Basket basket, int quantity) {
   if (items.containsKey(productID)) {
     basket = items.get(productID);
     basket.incrementQuantity(quantity);
   } else {
     items.put(productID, basket);
     numberOfItems++;
   }
 }
示例#4
0
 /**
  * BasketCart의 HashMap에 basket객체를 더해 준다. ProductId를 키로 하여 존재 유무를 확인하고 존재하면 quantity의 수를 증가 시킨다.
  * 존재하지 않으면 basket객체를 저장한다.
  *
  * @param String productID,Basket basket
  */
 public void add(String productID, Basket basket) {
   if (items.containsKey(productID)) {
     // 존재하면 수량을 증가시킨다
     basket = items.get(productID);
     basket.incrementQuantity();
   } else {
     // 존재하지 않으면 basket객체를 저장한다.
     items.put(productID, basket);
     numberOfItems++;
   }
 }