-name: std::string - sales_price_: long - cost price: long - items_in_stock_: int Product + Product(name_ref: std::string&, cost_price: long, sales_price: long) + set_name(name_ref: std::string&): void + set_sales_price(sales_price: long): void + set_cost_price (cost_price: long) : void + set_items_in_stock(items int) : void + name(): std::string + sales_price(): long +cost_price(): long + items_in_stock(): int + sell(number_items_to_sell : int): long + purchase(number_items_to_buy : int): long
Based on the class Product defined above, the member function sell() is now to be implemented. If number_items_to_sell is negative, then this variable is to be set to zero inside the function for further processing. When selling, two things can happen. First, you can have more items in stock than items to be sold. In this (good) case, the function is to reduce the number of items in stock by the number of items to be sold. Second, you have fewer items in stock than items to be sold. In this case, all items in stock are to be sold, and the number of items in stock is to be set to zero. In both cases, the function returns the money made during the sale (in Cents). This function definition is to be put into the file task5.cpp.

Unlock instant AI solutions
Tap the button
to generate a solution








