Assignment NP
Assignment NP
Assignment - Day 3
Concept: Abstraction &Polymorphism
Problems:
Derive Tablet, Syrup and Ointment classes from the Medicine class. Override the
displayLabel() function in each of these classes to print additional information
suitable to the type of medicine. For example, in case of tablets, it could be
“store in a cool dry place”, in case of ointments it could be “for external use only”
etc.
Create a class Square that implements Polygon and has the following member:
side float
Create another class Rectangle that implements Polygon and has the following member:
length float
breadth float
In another packagecom.test, create a class that imports the above package and
instantiates an object of the Square class and an object of the Rectangle class.
Call the methods on each of the classes to calculate the area and perimeter given the
side and the length/breadth of the Square class and the Rectangle class respectively.