Ejemplo 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;
     }
   }
 }
Ejemplo n.º 2
0
 public Special createSpecialWithItem(String name, MenuItem item, double price)
     throws PizzaException {
   Special temp = new Special(name.trim());
   if ((name.trim().equals(""))
       || (name == null)
       || (item == null)
       || (price < 0)
       || ((Double) price == null)) {
     throw new PizzaException(
         "Incorrect parameter createSpecialWithItem(<"
             + name.trim()
             + ">:String, <"
             + item.getName()
             + ">:MenuItem, <"
             + price
             + ">:double)");
   } else {
     // if special exists in system already, find it, replace the name
     if (parentSystem.getPizzaStore().checkSpecialsForItem(item)) {
       temp = parentSystem.getPizzaStore().findSpecialByItem(item);
       temp.setSpecialName(name);
       temp.setSpecialPrice(price);
     } else {
       temp.addItemToSpecial(item, price);
       parentSystem.getPizzaStore().getSpecials().add(temp);
     }
   }
   return temp;
 }