Tasks for you:
1.
Make a base class named Item then define its private and public members. Define a
constructor with parameters for both data members (Barcode, Item Name). You
should add default values for the parameters to provide a default constructor
for the class. In addition to the access methods setCode() and getCode(), you
are also required to define the methods scanner() and printer(). These methods
will simply output item data on screen or read the data of an item from the
keyboard.
2.
Define two derived classes PackedFood and FreshFood.
In addition to the Item class data, the PackedFood class should contain the
unit price. The FreshFood class should contain a weight and a price per
kilogram as data members. You are required to define a constructor with
parameters providing default-values for all data members in both classes. Also
define the access methods needed for the new data members.
No comments:
Post a Comment