Exemplo n.º 1
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;
 }