示例#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;
 }
示例#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;
 }
示例#3
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;
     }
   }
 }
示例#4
0
 public void removePizzaFromSpecial(Special special) throws PizzaException {
   if ((special == null) || !(parentSystem.getPizzaStore().getSpecials().contains(special))) {
     throw new PizzaException(
         "Incorrect parameter removePizzaFromSpecial(<" + special.getSpecialName() + ">:Special)");
   } else {
     special.removePizzaSizeFromSpecial();
   }
 }
示例#5
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);
   }
 }
示例#6
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;
     }
   }
 }