an oop us

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 1TF: Mark the following statements as true or false. All members of a struct must be of different types....
icon
Related questions
Question

write an oop using photos below

1)Write a member function named addDrug which accepts 3 parameters name, price, and quantity of a drug, then add it to the list
2) Write a member function named getDrug which accepts an integer parameter that represents the index (location) of the drug
then returns name and quantity of this drug from the specific location. (Remember: You should check the location if it is in the list
range or not. Otherwise, print "Out of range").
3) Write a member function named printAllHigher will accept a double parameter represents a price then, prints all drugs
name which prices are higher than the parameter.
4) Write a non-member function named largerPharmacy that takes 2 objects of type Pharmacy by reference and returns the
Pharmacy that contains number of drugs more than the other.
- The main is given to you.
Constraints
None
S Input Format
You must enter 3 drugs for the first pharmacy and 6 drugs for the second pharmacy (i.e. 9 string values for name,
9 double values for price, and 9 integer values for quantity)
followed by one double value
E Output Format
See the sample
O Sample #1
Input
Transcribed Image Text:1)Write a member function named addDrug which accepts 3 parameters name, price, and quantity of a drug, then add it to the list 2) Write a member function named getDrug which accepts an integer parameter that represents the index (location) of the drug then returns name and quantity of this drug from the specific location. (Remember: You should check the location if it is in the list range or not. Otherwise, print "Out of range"). 3) Write a member function named printAllHigher will accept a double parameter represents a price then, prints all drugs name which prices are higher than the parameter. 4) Write a non-member function named largerPharmacy that takes 2 objects of type Pharmacy by reference and returns the Pharmacy that contains number of drugs more than the other. - The main is given to you. Constraints None S Input Format You must enter 3 drugs for the first pharmacy and 6 drugs for the second pharmacy (i.e. 9 string values for name, 9 double values for price, and 9 integer values for quantity) followed by one double value E Output Format See the sample O Sample #1 Input
Use the following UML class diagrams for Pharmacy class and Drug struct to Complete the Pharmacy class by
writing the implementation of the required functions outside the class interface.
Pharmacy
Drug
drugs [60]: Drug
name: string
length: int
//number of drugs
price: double
+ Pharmacy ()
quantity: int
+ isFull(): bool
+ isEmpyt (): bool
+ getNumDrugs () : int
+ printAllDrugs () : void
+ addDrug (string, double, int): void
+ getDrug (int,string&,int&): void
+ printAllHigher (double): void
+ -Pharmacy ()
Transcribed Image Text:Use the following UML class diagrams for Pharmacy class and Drug struct to Complete the Pharmacy class by writing the implementation of the required functions outside the class interface. Pharmacy Drug drugs [60]: Drug name: string length: int //number of drugs price: double + Pharmacy () quantity: int + isFull(): bool + isEmpyt (): bool + getNumDrugs () : int + printAllDrugs () : void + addDrug (string, double, int): void + getDrug (int,string&,int&): void + printAllHigher (double): void + -Pharmacy ()
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Encryption and Decryption
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning