Created
May 31, 2019 09:01
-
-
Save jasongorman/1e07d7962b90cdf16ab20ec7ecccb41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ShoppingBasket { | |
private final List<BasketItem> basket = new ArrayList<>(); | |
void addItem(BasketItem basketItem) { | |
basket.add(basketItem); | |
} | |
double total() { | |
double total = basket.stream() | |
.mapToDouble(i -> i.getPrice() * i.getQuantity()) | |
.sum(); | |
return total; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment