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 removeItemFromSpecial(Special special) throws PizzaException {
   if (!(parentSystem.getPizzaStore().getSpecials().contains(special))
       || (special == null)
       || (special.getItem() == null)) {
     throw new PizzaException(
         "Incorrect parameter removeItemFromSpecial(<" + special.getSpecialName() + ">:Special)");
   } else {
     special.removeItemFromSpecial();
   }
 }
Exemplo n.º 3
0
 public void modifySpecialPrice(Special special, double price) throws PizzaException {
   if (!(parentSystem.getPizzaStore().getSpecials().contains(special))
       || (special == null)
       || (special.getItem() == null)
       || (price < 0)
       || (Double) price == null) {
     throw new PizzaException(
         "Incorrect parameter removeItemFromSpecial(<" + special.getSpecialName() + ">:Special)");
   } else {
     special.setSpecialPrice(price);
   }
 }