0% found this document useful (0 votes)
2 views1 page

Object Oriented Programming Exercise: UML Implementation

The document outlines an exercise for an Object Oriented Programming course at Lebanese University, focusing on creating classes and interfaces based on a UML diagram. It requires the implementation of an abstract class Medicine, an interface Taxable, and a class OverCounter, along with a DrugStore class that manages medicines. Additionally, a Test class is needed to demonstrate functionality such as adding medicines and calculating prices, including tax for over-the-counter items.

Uploaded by

Rayyan Mostapha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Object Oriented Programming Exercise: UML Implementation

The document outlines an exercise for an Object Oriented Programming course at Lebanese University, focusing on creating classes and interfaces based on a UML diagram. It requires the implementation of an abstract class Medicine, an interface Taxable, and a class OverCounter, along with a DrugStore class that manages medicines. Additionally, a Test class is needed to demonstrate functionality such as adding medicines and calculating prices, including tax for over-the-counter items.

Uploaded by

Rayyan Mostapha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like