I have three classes; Stamp, Letter and Parcel that implement an interface IProduct and they also have some of their own functionality.
public interface IP
Why can't I access the additional members of derived classes from a
List
?
That is because, IProduct
interface does not know about UnitPrice
, Destination
etc of the derived class properties.
Are you trying add the intelligence to calculate the Amount
to each of the derived class objects Stamp, Letter, Parcel ?
Then, I would say you need to redesign a bit and use the Decorator design pattern.
DerivedClass::Amount()
{
Base::Amount() +
//Amount logic based on derived class
}