Как можно вернуть значения int в такой ситуации?
import java.util.*;
public class ShoppingCart {
private Map<String, Purchase> shoppingCart = new HashMap<String, Purchase>();
public void add (String product, int price) {
Purchase purchase = new Purchase(product, 1, price);
shoppingCart.put(product, purchase);
}
public int totalPrice() {
//How do I accomplish this? I want to return all the prices summed together
}
}
}
Конструктор для метода покупки:
public Purchase(String product, int amount, int price) {