Advertisement
CSenshi

totalPrice

Aug 10th, 2020
1,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.29 KB | None | 0 0
  1.     public static double totalPrice(int userId) {
  2.         Map<Product, Integer> mp = getProductsByUserId(userId);
  3.         return mp.keySet()
  4.                 .stream()
  5.                 .map(product -> product.getPrice() * mp.get(product))
  6.                 .reduce(0.0, Double::sum);
  7.     }
  8.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement