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:
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:
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
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fde1da679-b360-4712-b298-5c18be8f5c44%2F3f8cb2e2-1be4-4b50-9c27-d2ee9f92547d%2Fnra5hfv_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education