I need to store the following line items on a receipt: quantity, description, upc, and price.
What is the best method in Java to store these? I need to print them to an output at some point by line, just like a receipt printer would. The number of elements in the collection should be arbitrary though because I will be adding and deleting elements.
5 item1 new item 324234 $4.99
1 item2 dish soap 34235346 $6.33
..and so on
I would think about creating some objects that would reflect the items you want to represent. For example, perhaps you might have a
Receiptobject that has aListofReceiptItems.Each of your items would contain the values you wish to keep track of
UPDATE:
To access the private methods, you would create a few getters or action methods. I’ve added a few above as an example.