4 ms·
I think this is made more complex and confusing than it should be. Notice that the author uses the word price (or row price) for two different things: the pric
by throwaway4good 6y ago
I think this is made more complex and confusing than it should be.
Notice that the author uses the word price (or row price) for two different things: the price of a product and the total (price * quantity) in a shopping cart line (cart row).
The set of CartRow can be calculated as a straight forward entrySet().map(...) of the shopping cart in products map form (Map<Product, Integer>).
The PriceAndRows object is really the total for all the cart rows and the union of all the cart rows. Both things can be calculated as a straight forward map / reduce.