Interface ICartService

All Known Implementing Classes:
CartServiceImpl

public interface ICartService
Interface for managing the shopping cart operations.
  • Method Details

    • addToCart

      Cart addToCart(Product product, Cart cart)
      Adds a product to the cart. If the product is already in the cart, increases its quantity.
      Parameters:
      product - the product to add
      cart - the cart to which the product is added
      Returns:
      the updated cart
    • findItem

      Optional<CartItem> findItem(Cart cart, Product product)
      Finds an item in the cart based on the product.
      Parameters:
      cart - the cart to search
      product - the product to find
      Returns:
      an optional containing the found cart item, or empty if not found
    • addCartItemToCart

      Cart addCartItemToCart(CartItem cartItem, Cart cart)
      Adds a cart item to the cart.
      Parameters:
      cartItem - the cart item to add
      cart - the cart to which the item is added
      Returns:
      the updated cart
    • removeCartItemFromCart

      Cart removeCartItemFromCart(CartItem cartItem, Cart cart)
      Removes a cart item from the cart.
      Parameters:
      cartItem - the cart item to remove
      cart - the cart from which the item is removed
      Returns:
      the updated cart
    • decreaseCartItemFromItems

      Cart decreaseCartItemFromItems(Cart cart, Product product)
      Decreases the quantity of a product in the cart. If the quantity reaches 0, removes the item from the cart.
      Parameters:
      cart - the cart
      product - the product to decrease the quantity of
      Returns:
      the updated cart
    • checkout

      void checkout()
      Performs checkout for the cart.