Can anyone provide an algorithm to the problem below?.
I'm stumped with this question.
Exercise 5: Let us consider an example of an inventory control of products in a store. One way of recording the details of the products is to record their names, code number, total items in the stock and the price of each item.
Data
Product_name
Product_code
Unit_Price
Methods
GetProducts()
DisplayProducts()
(i) Define a class called ‘product’ with data items product_name, product_code, and Unit_price. Save the class as a header file, i.e. **.h.
(ii) Define a constructor ‘product()’with parameter for dynamic initialization
(iii)Define the methods GetProducts() and DiaplayProducts().
(iv) Write the main program to test the product system.
The above system has to be upgraded by using the sales information such as
Data
Order_no
Product_code
Quantity
Methods
Total_price() calculated as Unit_Price*Quantity
Invoice() shown as below
should be included in the upgraded system.
(v) Define a derived class called ‘Order’ which will have the above member data and methods.
(vi) Define the method Total_price() and Invoice() for displaying an invoice of an order as follows
------------------------------------------------------
| ABC Company Invoice Date: |
------------------------------------------------------
| Order no | |
| Product code | |
| Quantity @ Unit_price | *** |
------------------------------------------------------
| Total price | *** |
------------------------------------------------------
Seems pretty straightforward to me. He tells you what class to make, and what members to give it. Just do what it says. I don't see much room for error here.