This is a project where I built a device that could conceivably serve as a mobile objects-in-cart tracker.
I used the button-and-tilt entry method so users could go through the different items in my fake online grocery store. After picking the item, users click the button multiple times to represent the quantity of an item they'd like to buy. (Ex: click five times to buy five of an item).
Implementation
Whenever the user makes a submission, the item and quantity is sent to a database that contains all of the items currently in the user’s cart.
To find the total price of all the items in the user’s cart, I went through each item in the database, multiplied the quantity of each item by its price, and added all of these values together. To checkout/empty the cart, I deleted all of the items in the database.