The self-service point-of-sale system you are implementing is a customer-facing touch-screen kiosk, positioned in a fast-food restaurant for customers to build their order. Customers select various menu items and are continuously presented with the state of their order: a list of items with their prices, and the total cost of the order.
For this part, you are asked to implement the userSelectedItem method, as it manipulates the active order (Order class) and calls the Display object.
Requirements are:
- Assume that when the customer selects an item, your
userSelectedItemmethod gets invoked by the system. - The textual display must be updated to reflect the current state of the customer’s order within each call to
userSelectedItem. - Include a list of items, their quantities, the price of each line item, and the total price.
Example: when a user has selected two hamburgers ($6 each), fries ($3), and soda ($2), the display should show:
2x hamburger 12.0
1x fries 3.0
1x soda 2.0
Total: 17.0
(Note: the order of lines is not a requirement)
This problem asks you to maintain an order in a point-of-sale kiosk and refresh the on-screen text every time a customer selects an item. The core idea is to track item counts in the active order, compute each line total as quantity times unit price, and render the full summary with the grand total after every selection. A hash map / dictionary is the natural data structure for aggregating quantities efficiently.