Example #1
0
 public synchronized void deleteOpt(String opsetName, String optName) {
   OptionSet OptList = opsetList.get(opsetName);
   for (int j = 0; j < OptList.getOpt().size(); j++) {
     if (OptList.getOpt().get(j).getName().equals(optName)) {
       OptList.getOpt().remove(j);
       break;
     }
   }
 }
Example #2
0
 public synchronized Option findOptWithName(String optName) {
   Iterator<String> iter = opsetList.keySet().iterator();
   while (iter.hasNext()) {
     String key = iter.next();
     OptionSet optList = opsetList.get(key);
     for (int j = 0; j < optList.getOpt().size(); j++) {
       if (optList.getOpt().get(j).getName().equals(optName)) {
         return optList.getOpt().get(j);
       }
     }
   }
   return null;
 }
Example #3
0
 public synchronized void updateOpt(String opsetName, String optName, float price) {
   try {
     if (!opsetList.containsKey(opsetName))
       throw new AutoOptionException(
           "The option set name entered is not found. Please check!" + "\nNo update is made.");
     else {
       OptionSet OptList = opsetList.get(opsetName);
       boolean optNameExists = false;
       for (int j = 0; j < OptList.getOpt().size(); j++) {
         if (OptList.getOpt().get(j).getName().equals(optName)) {
           OptList.getOpt().get(j).setPrice(price);
           optNameExists = true;
           break;
         }
       }
       if (optNameExists == false)
         throw new AutoOptionException(
             "The option name entered is not found. Please check!" + "\nNo update is made.");
     }
   } catch (AutoOptionException e) {
     System.out.println(e.getMsg());
   }
 }