int main(int argc, const char * argv[]) { Products php("PHP", 23, 10); Products java("JAVA", 23, 1); Inventory inv; inv.insert(php); inv.insert(java); std::cout << std::endl; inv.show(); std::cout << std::endl; std::cout << "Total quantity of all products: " << inv.countQuantity(); std::cout << std::endl; return 0; }
bool Trade::perform(TradedItems items, Inventory &inv1, Inventory &inv2) { for (TradedItems::const_iterator i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->id != inv1.getItem(i->slot) || inv1.removeFromSlot(i->slot, i->amount) != 0 || inv2.insert(i->id, i->amount) != 0) { return false; } } return true; }
inline void note (Inventory & s, char c, char i) { if (c > 0) s.insert (Quantity (c, i)); }