/** Function to get all the non-discounted products */ public List<Product> getAllNonDiscoutedProducts(int userID) { List<Product> nonDiscountedProducts = null; try { nonDiscountedProducts = ProductDao.getNonDiscountedProducts(userID); } catch (Exception e) { e.printStackTrace(); } return nonDiscountedProducts; }
/** Function to get all the discounted products */ public List<Product> getAllDiscoutedProducts(int userID) { List<Product> discountedProducts = null; try { discountedProducts = ProductDao.getDiscountedProducts(userID); Map<String, String> userCategory = UserDAO.getUserCategory(userID); for (int i = 0; i < discountedProducts.size(); i++) { double productPrice = discountedProducts.get(i).getProductPrice(); double x = productPrice * (Double.parseDouble(userCategory.get("categoryDiscount")) / 100); double y = productPrice - x; discountedProducts.get(i).setProductDiscountedPrice(y); } } catch (Exception e) { e.printStackTrace(); } return discountedProducts; }