#Feat - Preis berechnung
parent
ba178e05fd
commit
76406349f7
|
|
@ -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
|
||||
|
|
@ -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<CartPosition> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue