The LineItem class needs to format the item.
To format each item the total for that line item is needed. So the LineItem has that responsibility, too.
| LineItem | |
|---|---|
| responsibility | collaborator(s) |
| format the line item | ? |
| get line total | |
How does the LineItem class get the line total?
It depends on the properties of a LineItem object. Quantity is not a property of a Product; it is a property of a LineItem.
That is, a LineItem consists of a Product and a Quantity.
What about price? The Price is a property of a Product.
So the LineItem will need to use the Product class to get the Product price:
| LineItem | |
|---|---|
| responsibility | collaborator(s) |
| format the line item | Product |
| get line total | |
The get line total will need the quantity (as a parameter).