-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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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. 

-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
Transcribed Image Text:-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
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education