Package springboot.bg.harisauto.cart
Class ShoppingCart
java.lang.Object
springboot.bg.harisauto.cart.ShoppingCart
Shopping cart stored in the user's session.
- Author:
- Kristian Popov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItem(CarService service) Add item to the cart.voidclear()Clear the cart.intgetCount()Get the number of items in the cart.getTotal()Calculate the total price of the items in the cart.voidremoveItem(UUID serviceId) Remove item from the cart.
-
Constructor Details
-
ShoppingCart
public ShoppingCart()
-
-
Method Details
-
addItem
Add item to the cart.- Parameters:
service- The service to add.
-
removeItem
Remove item from the cart.- Parameters:
serviceId- The service id.
-
clear
public void clear()Clear the cart. -
getCount
public int getCount()Get the number of items in the cart.- Returns:
- The number of items.
-
getTotal
Calculate the total price of the items in the cart.- Returns:
- The total price.
-