Lebanese University
Faculty of Sciences – section 5
I2211 – Object Oriented Programming
Exercise 4
Consider the following UML diagram:
1. Create the abstract class Medicine as presented in the above UML. Note that price should be
positive (throw a custom exception if not).
2. Create the interface Taxable.
3. Implement the class OverCounter. Note that over the counter medicines are taxable with a 10%
addition to the price.
4. Implement the class DrugStore, Note that:
• The buyMedicine method searches for a medicine with the given name in the ArrayList and
returns its price. If it turned out to be an over the counter medicine, then the price after tax is
returned.
• The method getOverCounterMeds returns an array of type OverCounter that contains all of the
Over the Counter medicines found in the ArrayList.
5. Implement a Test class with a main method that performs the following operations:
• Create a DrugStore object (choose any name and location)
• Add three medicines to it of your choice (Not from the user)
• Read the name of any medicine from the user, buy it and display its price
• Display the number of Over the Counter medicines in the drug store
Page 1/1