I'm struggling with the following:
I'm building an order system. I have an ArrayList "sales", the list contains some variables and a HashSet with the items that were sold as part of the order. There's a Part class with getters for the part name (getName
) and part price (getPrice
).
The "sales" ArrayList contains: (int orderNumber, LocalDate date, OrderItem orderItem)
And looks like this:
Order: 1, date: 2020-02-23, Items: [part: Monitor, quantity: 3, part: CPU, quantity: 2]
Order: 2, date: 2020-02-23, Items: [part: Headset, quantity: 1, part: Case, quantity: 1]
Order: 3, date: 2020-02-23, Items: [part: CPU, quantity: 10, part: Keyboard, quantity: 10]
Each OrderItem contains:
(Part part, int quantity)
. The Part class contains (String partName, double price)
.
What I want to do is create a new collection that lists the total number of parts that were sold on a day, like this:
Monitor 3
CPU 12
Headset 1
Case 1
Keyboard 10
How can I do this?