예제 #1
0
 /**
  * TODO 修改购物车里食物的数量(可选).
  *
  * @see com.yummy.service.ICartManager#update(int, int)
  */
 public void update(int id, int quantities) {
   // TODO Auto-generated method stub
   for (int i = 0; i < items.size(); i++) {
     ItemDTO temp = items.get(i);
     if (temp.getId() == id) {
       temp.setOrderCount(quantities);
     }
   }
 }
예제 #2
0
 /**
  * TODO 判断购物车是否已有相同食物存在(可选).
  *
  * @see com.yummy.service.ICartManager#isItemExist(int)
  */
 public boolean isItemExist(int id) {
   // TODO Auto-generated method stub
   boolean flag = false;
   for (int i = 0; i < items.size(); i++) {
     ItemDTO temp = items.get(i);
     if (temp.getId() == id) {
       flag = true;
     }
   }
   return flag;
 }
예제 #3
0
 /**
  * TODO 删除购物车里面的食物(可选).
  *
  * @see com.yummy.service.ICartManager#delete(int)
  */
 public void delete(int id) {
   // TODO Auto-generated method stub
   Iterator iterator = items.iterator();
   while (iterator.hasNext()) {
     ItemDTO temp = (ItemDTO) iterator.next();
     if (temp.getId() == id) {
       items.remove(temp);
       break;
     }
   }
 }