PRASHNIKAप्रश्निका
‹ Back to the paper

A super class Godown has been defined to store the details of the stock of a retail store. Define a…

Computer Science20224 marksProgram
A super class Godown has been defined to store the details of the stock of a retail store. Define a subclass Update to store the details of the items purchased with the new rate and update the stock. Some of the members of both the classes are given below: Class name: Godown Data members/instance variables: item: to store the name of the item qty: to store the quantity of an item in stock rate: to store the unit price of an item amt: to store the net value of the item in stock Member functions/methods: Godown(...): parameterized constructor to assign value to the data members void display(): to display the stock details Class name: Update Data members/instance variables: pur_qty: to store the purchase quantity pur_rate: to store the unit price of the purchased item Member functions/methods: Update(...): parameterized constructor to assign values to the data members of both the classes void update(): to update the stock by adding the previous quantity by the purchased quantity and replace the rate of the item if there is a difference in the purchase rate. Also update the current stock value as: $(quantity * unit\ price)$ void display(): to display the stock details before and after updating Assume that the super class Godown has been defined. Using the concept of inheritance, specify the class Update giving details of the constructor, void update() and void display(). The super class, main function and algorithm need NOT be written.

Answer

No answer yet.

Inheritance, Interfaces and Polymorphism

From ISC 2022 Computer Science - Specimen paper (Semester 2), Paper 1, question 7.