I have the folling code that is part of a programm the thing is I cant get it to work. Im suppose to make the sale if it is allowed, otherwise throw an exception or let an exception propagate. In this context allowed means that the product's reduceInventory() and the customer's processPurchase() functions would not throw an exception and the product and customer must exist.
void Store::sellProduct(int customerID, int productID, int quantity) {
Customer b = getCustomer(customerID);
Product p = getProduct(productID);
p.reduceInventory(quantity);
b.processPurchase((p.getPrice()*quantity), p);
}
Aucun commentaire:
Enregistrer un commentaire