Example #1
0
 /**
  * Define update functions, which used to update values of specific automobile option sets and
  * options.
  */
 public void updateOpsetName(String opsetName, String newName) {
   try {
     if (!opsetList.containsKey(opsetName))
       throw new AutoOptionException(
           "The option set name entered is not found. Please check!" + "\nNo update is made.");
     else {
       opsetList.put(newName, opsetList.get(opsetName));
       opsetList.remove(opsetName);
       System.out.println("Updated!");
     }
   } catch (AutoOptionException e) {
     System.out.println(e.getMsg());
   }
 }
Example #2
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());
   }
 }