Esempio 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;
 }
Esempio n. 2
0
 public Special addPizzaToSpecial(Special special, PizzaSize size, double price)
     throws PizzaException {
   if ((special == null)
       || !(parentSystem.getPizzaStore().getSpecials().contains(special))
       || (size == null)
       || !(parentSystem.getPizzaStore().getMenu().getPizzaSizes().contains(size))
       || (price < 0)
       || ((Double) price == null)) {
     throw new PizzaException(
         "Incorrect parameter addPizzaToSpecial(<"
             + special.getSpecialName()
             + ">:Special, <"
             + size.getDesc()
             + ">:PizzaSize, <"
             + price
             + ">:double)");
   } else {
     if (special.getSize() == null) {
       size.setPrice(price);
       special.addPizzaToSpecial(size, price);
       return special;
     } else {
       special.removePizzaSizeFromSpecial();
       special.addPizzaToSpecial(size, price);
       return special;
     }
   }
 }