ShoppingCart

class ShoppingCart

ShoppingCart class

A simple shopping cart class that could add product, count the number of products, sum for total price

Constructors

ShoppingCart
Link copied to clipboard
fun ShoppingCart()

Create an empty cart

Functions

add
Link copied to clipboard
fun add(product: Product)

Add a product in shopping cart

count
Link copied to clipboard
fun count(): Int

Calculate the quantity of products

totalPrice
Link copied to clipboard
fun totalPrice(): Int

Calculate products' price