diff --git a/Shop/resources/quellen.txt b/Shop/resources/quellen.txt index b7181b5..31b18fb 100644 --- a/Shop/resources/quellen.txt +++ b/Shop/resources/quellen.txt @@ -19,3 +19,5 @@ https://www.youtube.com/watch?v=eHjbvgw4hsI Baeldung - ConcurrentModificationException https://www.baeldung.com/java-concurrentmodificationexception +Build an Online Shopping Cart System Using OOP in Java - Nakul Mitra +https://towardsdev.com/build-an-online-shopping-cart-system-using-oop-in-java-e8e5797f8664 \ No newline at end of file diff --git a/Shop/src/de/th_mannheim/informatik/main/java/shop/backend/Cart.java b/Shop/src/de/th_mannheim/informatik/main/java/shop/backend/Cart.java index f04bc7c..2c85252 100644 --- a/Shop/src/de/th_mannheim/informatik/main/java/shop/backend/Cart.java +++ b/Shop/src/de/th_mannheim/informatik/main/java/shop/backend/Cart.java @@ -4,7 +4,10 @@ import java.util.ArrayList; import java.util.List; public class Cart { - +/* +Ich hätte auch über eine ProdukteListe Iterieren können, +jedoch würde dann die Klasse CartPositions wegfallen + */ private List positions; public Cart(){ @@ -38,6 +41,15 @@ public void removeProduct(int productID){ } } + public double getTotalPrice() { + double sum = 0; + for(CartPosition pos : positions){ + sum += pos.getTotalPrice(); + } + return sum; + } + + }