onsider the scenario of a Pharmacy Management System. The following UML Class diagram shows a hierarchy of some of the classes in the system. (Shown in Picture) The StateManager Interface is a generic interface which has two methods changeState (boolean : status). This method is used to change the status of InvoiceItem and PrescriptionItem. The possible status for InvoiceItem can be (Available – true or Unavailable - false), whereas PrescriptionItem has status (Recommended-true or Prohibited – false) passed to the method as an argument. The reset () method sets the default value for both InvoiceItem and PrescriptionItem.   The Item class is self-explanatory. It implements the StateManager interface, and has toString method which prints the information in the following format. "Item Name: <> (<>)” e.g. Item Name: Panadol (223) Two classes PrescriptionItem and InvoiceItem are inherited from Item class representing the items that can be sold with doctor’s prescription and without prescription respectively with following functionalities: The constructors of PrescriptionItem and InvoiceItem initialize fields to appropriate parameters as shown in the diagram.  Both PrescriptionItem and InvoiceItem classes will override the changeStatus Inside PrescriptionItem, it will set the value to available (true) or unavailable (flase), while in InvoiceItem class it will set value to recommended (true) or prohibited (false). However, the default value in both classes will be set to false.                                     The computePrice method returns (does not print) the price of invoice item according to price, quantity and discount rate (percentage).             The toString method of InvoiceItem class prints the invoice item in the following format.                    Item Name: <> (<>), Price: <> Quantity: <>Total: <> (@<> % discount)  E.g.,  Item Name: Panadol (223),  Price: 2, Quantity: 150, Total: 270 (@10 % discount)   Finally, write a driver class named ItemTester to test the functionality of PrescriptionItem and InvoiceItem classes. Create at least two objects of each class polymorphically by initializing objects of subclasses to reference of a super class and print the details using toString method by iterating through the objects of both classes.

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
icon
Related questions
Question

Consider the scenario of a Pharmacy Management System. The following UML Class diagram shows a hierarchy of some of the classes in the system. (Shown in Picture)

The StateManager Interface is a generic interface which has two methods changeState (boolean : status). This method is used to change the status of InvoiceItem and PrescriptionItem. The possible status for InvoiceItem can be (Available – true or Unavailable - false), whereas PrescriptionItem has status (Recommended-true or Prohibited – false) passed to the method as an argument. The reset () method sets the default value for both InvoiceItem and PrescriptionItem.  

The Item class is self-explanatory. It implements the StateManager interface, and has toString method which prints the information in the following format.
"Item Name: <<name>> (<<id>>)” e.g. Item Name: Panadol (223)

Two classes PrescriptionItem and InvoiceItem are inherited from Item class representing the items that can be sold with doctor’s prescription and without prescription respectively with following functionalities:

  • The constructors of PrescriptionItem and InvoiceItem initialize fields to appropriate parameters as shown in the diagram. 
  • Both PrescriptionItem and InvoiceItem classes will override the changeStatus Inside PrescriptionItem, it will set the value to available (true) or unavailable (flase), while in InvoiceItem class it will set value to recommended (true) or prohibited (false). However, the default value in both classes will be set to false.                                    
  • The computePrice method returns (does not print) the price of invoice item according to price, quantity and discount rate (percentage).            
  • The toString method of InvoiceItem class prints the invoice item in the following format.                   

    Item Name: <<name>> (<<id>>), Price: <<price>> Quantity: <<quantity>>Total:

    <<computePrice()>> (@<<discount>> % discount) 

    E.g.,  Item Name: Panadol (223),  Price: 2, Quantity: 150, Total: 270 (@10 % discount)

 

Finally, write a driver class named ItemTester to test the functionality of PrescriptionItem and InvoiceItem classes. Create at least two objects of each class polymorphically by initializing objects of subclasses to reference of a super class and print the details using toString method by iterating through the objects of both classes.                         

<<interface>>
StateManager
+ reset(): void
+ changeStatet): void
Item
<cabstract>>
- id: int
- name: String
+ Item(id: int, name: String)
+tostring() : String
Invoiceltem
PrescriptionItem
potency: int
dose: int
CUrrentStatus: boolean
price: float
quantity: int
discount: float
- Availability: int
Prescriptionltemé potency: int, dose: int)
+ changeState(): void
+ reset(): void
+ Invoiceltem price: fleat, quantity: int)
+ changestate(): void
+ reset(): void
+ computePrice) : float
+ tostring() : String
Transcribed Image Text:<<interface>> StateManager + reset(): void + changeStatet): void Item <cabstract>> - id: int - name: String + Item(id: int, name: String) +tostring() : String Invoiceltem PrescriptionItem potency: int dose: int CUrrentStatus: boolean price: float quantity: int discount: float - Availability: int Prescriptionltemé potency: int, dose: int) + changeState(): void + reset(): void + Invoiceltem price: fleat, quantity: int) + changestate(): void + reset(): void + computePrice) : float + tostring() : String
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Software Development
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education