public Model getAuto(String modelName) { _autoModel = _autoModelGroup.get(modelName); if (_autoModel == null) { System.err.println("Model not found! Model: " + modelName); } return _autoModel; }
// prints to console based on if the model name is found public void printAuto(String modelName) { _autoModel = _autoModelGroup.get(modelName); if (_autoModel != null) { // using toStringWChoices to show optionChoice is functional System.out.println(_autoModel.toStringWChoices(true)); System.out.print("Price with selected options(may be defaults):"); System.out.println(_autoModel.getTotalPrice()); } else System.out.print("Model name" + modelName + "not found"); }
public void updateOptionSetName(String modelName, String optionSetName, String newName) { int setIndex; _autoModel = _autoModelGroup.get(modelName); if (_autoModel != null) { setIndex = _autoModel.findOptionSetIndex(optionSetName); if (setIndex != -1) { _autoModel.updateOptionSetName(setIndex, newName); } } }
// optionName goes with optionset, optVal is the String property in an option. public void updateOptionPrice( String modelName, String optionName, String optVal, float newprice) { int setIndex; _autoModel = _autoModelGroup.get(modelName); if (_autoModel != null) { setIndex = _autoModel.findOptionSetIndex(optionName); if (setIndex != -1) { _autoModel.updateOptionPrice(setIndex, optVal, newprice); } } }
// optionName goes with optionset, optVal is the String property in an option. public void updateOptionValue( String modelName, String optionName, String oldOptVal, String newOptVal) { int setIndex; _autoModel = _autoModelGroup.get(modelName); if (_autoModel != null) { setIndex = _autoModel.findOptionSetIndex(optionName); if (setIndex != -1) { if (_autoModel.updateOptionName(setIndex, oldOptVal, newOptVal)) System.out.println(newOptVal + " set!"); } } }
// a separate path with waits, just in case I forget to remove sleep() for the next lab. public void waitUpdateOptionValue( String modelName, String optionName, String oldOptVal, String newOptVal) { System.out.println( "Demonstrating Thread named " + Thread.currentThread().getName() + " and Setting " + oldOptVal + " to " + newOptVal); int setIndex; _autoModel = _autoModelGroup.get(modelName); if (_autoModel != null) { setIndex = _autoModel.findOptionSetIndex(optionName); if (setIndex != -1) { if (_autoModel.updateOptionName2(setIndex, oldOptVal, newOptVal)) { System.out.println(newOptVal + " set and updateOptionName2 exited."); } else { System.out.println(newOptVal + " NOT set but updateOptionName2 exited."); } } } System.out.println(Thread.currentThread().getName() + " done."); }
public ArrayList<String> getModelNameList() { ArrayList<String> modelList = new ArrayList<String>(); modelList.addAll(_autoModelGroup.keySet()); return modelList; }
public int countAutos() { return _autoModelGroup.size(); }
public boolean isAutoHere(String modelName) { return (_autoModelGroup.containsKey(modelName)); }
public void addAuto(Model autoModel) { if (!_autoModelGroup.containsKey(autoModel.getModelName())) { _autoModelGroup.put(autoModel.getModelName(), autoModel); } }
public void removeAuto(String modelName) { _autoModelGroup.remove(modelName); }
public void updateOptionChoice(String modelName, String optSetName, String optName) { _autoModel = _autoModelGroup.get(modelName); _autoModel.setOptionChoice(optSetName, optName); }
public ArrayList<String> getOptionSetNames(String modelName) { return _autoModelGroup.get(modelName).getAllOptSetNames(); }