How does one return the int values in a situation like this?
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
}
}
}
The constructor for the purchase method is:
public Purchase(String product, int amount, int price) {