/** Updates the food item list stored in the order based on the quantity map. */ private void updateOrderFoodItemList() { // Filter out the list of pizzas in the order. ArrayList<PizzaFoodItem> pizzaList = new ArrayList<PizzaFoodItem>(); for (FoodItem item : _currentOrder.getFoodItems()) { if (item instanceof PizzaFoodItem) { pizzaList.add((PizzaFoodItem) item); } } // Remove everything from the list. _currentOrder.getFoodItems().clear(); // Add the pizzas. _currentOrder.getFoodItems().addAll(pizzaList); // Add the sides to the order according to the // quantity map. for (SideFoodItem side : _quantityMap.keySet()) { // Duplicate this side the appropriate number of times. for (int i = 0; i < _quantityMap.get(side); i++) { SideFoodItem duplicateItem = new SideFoodItem( side.getName(), side.getPrice(), side.getPrepTime(), side.getCookTime(), side.getOvenSpaceUnits()); _currentOrder.addFoodItem(duplicateItem); } } }