Exemplo n.º 1
0
 public Special addItemToSpecial(Special special, MenuItem item, double price)
     throws PizzaException {
   if ((special == null)
       || !(parentSystem.getPizzaStore().getSpecials().contains(special))
       || (item == null)
       || !(parentSystem.getPizzaStore().getMenu().getMenuItems().contains(item))
       || (price < 0)
       || ((Double) price == null)) {
     throw new PizzaException(
         "Incorrect parameter addItemToSpecial(<"
             + special.getSpecialName()
             + ">:Special, <"
             + item.getDesc()
             + ">:MenuItem, <"
             + price
             + ">:double)");
   } else {
     // Given good params and doesn't already have item
     if (special.getItem() == null) {
       item.setPrice(price);
       special.addItemToSpecial(item, price);
       return special;
     }
     // Given good params but already has item. Create new special, add
     // to specials
     else {
       Special temp = new Special(special.getSpecialName());
       temp.addItemToSpecial(item, price);
       parentSystem.getPizzaStore().getSpecials().add(temp);
       return temp;
     }
   }
 }
Exemplo n.º 2
0
 public void removeItemFromMenu(MenuItem item) throws PizzaException {
   if (!(parentSystem.getPizzaStore().getMenu().getMenuItems().contains(item)) || (item == null)) {
     throw new PizzaException(
         "Incorrect parameter removeItemFromMenu(<" + item.getDesc() + ">:Item)");
   } else {
     parentSystem.getPizzaStore().getMenu().getMenuItems().remove(item);
   }
 }