Package bookstoreAcceptable
Class ShoppingCart
- java.lang.Object
-
- bookstoreAcceptable.ShoppingCart
-
public class ShoppingCart extends java.lang.Object
Shopping Cart
Class responsible for storing all the items that are selected from the user.- Since:
- 2017-07-17
- Version:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description ShoppingCart()
-
Method Summary
Modifier and Type Method Description int
addItem(Item item)
Adds an item to the cartjava.util.ArrayList<Item>
getItems()
float
getTotalCost()
int
removeItem(int anId)
Removes the item in the selected position Returns a diagnostic message in case of wrong itemjava.lang.String
showDetails()
Displays the details of each item in the cart in the console.
-
-
-
Method Detail
-
addItem
public int addItem(Item item)
Adds an item to the cart- Parameters:
item
- : item for addition- Returns:
- an int with the number of the items in the cart
-
removeItem
public int removeItem(int anId)
Removes the item in the selected position Returns a diagnostic message in case of wrong item- Parameters:
anId
- : id of the item for deletion- Returns:
- an int with the number of the items in the cart
-
getTotalCost
public float getTotalCost()
- Returns:
- the total cost of selected items
-
getItems
public java.util.ArrayList<Item> getItems()
- Returns:
- the list of all items which are added to the cart
-
showDetails
public java.lang.String showDetails()
Displays the details of each item in the cart in the console.
-
-