Assume there is a need to design a stock-control program for drugs used due to COVID-19 pandemic at EMU. Write C++ code to create emudrugstore class and main( ) function using given specifications. emudrugstore Data members: drug serial number (long), drug name (string), price (double), drug serial number counter (static long - Initial value should be 100), total drug counter (static integer - Initial value should be 0), total drug price (static double - Initial value should be 0.0) Methods:

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.1: Providing Class I/o Capabilities
Problem 8E
icon
Related questions
Topic Video
Question

C++ Programmming

 
1. Assume there is a need to design a stock-control program for drugs used due to COVID-19 pandemic at EMU. Write
C++ code to create emudrugstore class and main( ) function using given specifications.
emudrugstore
Data members:
drug serial number (long),
drug name (string).
drug price (double),
drug serial number counter (static long - Initial value should be 100),
total drug counter (static integer - Initial value should be 0),
total drug price (static double - Initial value should be 0.0)
Methods:
emudrugstore(string=“ “, double=0.0) /drug name and price must have default values
emudrugstore(const drugstore &)
emudrugstore( )
Read the instructions given below:
• Whenever a new object is created (this means; whenever any constructor is executed) ;
o compiler should assign a unique value for drug serial number,
o total drug price should be increased by drug price value,
o total drug counter should be increased by 1.
• Destructor prints an appropriate message on screen when the object is destroyed. (ie: "Panadol (dname) object
has been destroyed")
• Do not forget to initialize all static data members.
Additionally do the following steps to complete "emudrugstore" class;
Getter methods for every static and non-static members should be created. Remember that getter methods
return the corresponding data member.
• Setter methods should be friend functions of emudrugstore class. Therefore for every non-static member, create
setter method using friend function approach. Remember that setter methods receive a parameter and change
the corresponding data member.
USE this pointer in your class
a) Write a C++ code to create emudrugstore class (emudrugstore.h) using the specifications provided above. Use
appropriate (preferably short) names for data members and methods.
b) Write a complete C++ code that will include the following steps to create main function (emudrugstore.cpp).
• Include necessary header files,
• Create a dynamic object that will execute the default constructor,
• Create another dynamic object that will execute the parameterized constructor,
Create a dynamic array object which stores data for 30 drugs,
Call necessary method(s)
o to set a new drug name for dobj1 object, (ex: panadol)
o to change the drug price of second dynamic object to 20.18,
o to change the drug name of the object that is in the 3rd location of the array, (pass any drug name
you want),
o to display the drug serial number and the drug name of the object that is in the 5th location of the
array,
o to display drug name, drug price and drug serial number of the dynamic array object in row-wise,
o to display the current values of total drug count and total drug price,
• Delete all objects you have created.
Transcribed Image Text:1. Assume there is a need to design a stock-control program for drugs used due to COVID-19 pandemic at EMU. Write C++ code to create emudrugstore class and main( ) function using given specifications. emudrugstore Data members: drug serial number (long), drug name (string). drug price (double), drug serial number counter (static long - Initial value should be 100), total drug counter (static integer - Initial value should be 0), total drug price (static double - Initial value should be 0.0) Methods: emudrugstore(string=“ “, double=0.0) /drug name and price must have default values emudrugstore(const drugstore &) emudrugstore( ) Read the instructions given below: • Whenever a new object is created (this means; whenever any constructor is executed) ; o compiler should assign a unique value for drug serial number, o total drug price should be increased by drug price value, o total drug counter should be increased by 1. • Destructor prints an appropriate message on screen when the object is destroyed. (ie: "Panadol (dname) object has been destroyed") • Do not forget to initialize all static data members. Additionally do the following steps to complete "emudrugstore" class; Getter methods for every static and non-static members should be created. Remember that getter methods return the corresponding data member. • Setter methods should be friend functions of emudrugstore class. Therefore for every non-static member, create setter method using friend function approach. Remember that setter methods receive a parameter and change the corresponding data member. USE this pointer in your class a) Write a C++ code to create emudrugstore class (emudrugstore.h) using the specifications provided above. Use appropriate (preferably short) names for data members and methods. b) Write a complete C++ code that will include the following steps to create main function (emudrugstore.cpp). • Include necessary header files, • Create a dynamic object that will execute the default constructor, • Create another dynamic object that will execute the parameterized constructor, Create a dynamic array object which stores data for 30 drugs, Call necessary method(s) o to set a new drug name for dobj1 object, (ex: panadol) o to change the drug price of second dynamic object to 20.18, o to change the drug name of the object that is in the 3rd location of the array, (pass any drug name you want), o to display the drug serial number and the drug name of the object that is in the 5th location of the array, o to display drug name, drug price and drug serial number of the dynamic array object in row-wise, o to display the current values of total drug count and total drug price, • Delete all objects you have created.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning