Exemplo n.º 1
0
 public Special createSpecialWithPizza(String name, PizzaSize size, double price)
     throws PizzaException {
   Special temp = new Special(name);
   if ((name.trim().equals(""))
       || (name == null)
       || (size == null)
       || !(parentSystem.getPizzaStore().getMenu().getPizzaSizes().contains(size))
       || (price < 0)
       || ((Double) price == null)) {
     throw new PizzaException(
         "Incorrect parameter createSpecialWithPizza(<"
             + name.trim()
             + ">:String, <"
             + size.getDesc()
             + ">:PizzaSize, <"
             + price
             + ">:double)");
   } else {
     // if special exists for size already, set that special's name to the new name.
     if (parentSystem.getPizzaStore().checkSpecialsForPizzaSize(size)) {
       temp = parentSystem.getPizzaStore().findSpecialBySize(size);
       temp.setSpecialName(name);
     } else {
       temp.addPizzaToSpecial(size, price);
       parentSystem.getPizzaStore().getSpecials().add(temp);
     }
   }
   return temp;
 }
Exemplo 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;
 }