Can an interface be implemented across an aggregate/composite class in vb.net?
- by Casey
VB.NET .NET 3.5
I have an aggregate class called Package as part of a shipping system. Package contains another class, BoxType . BoxType contains information about the box used to ship the package, such as length, width, etc. of the Box.
Package has a method called GetShippingRates. This method calls a separate helper class, ShipRater, and passes the Package itself as an argument. ShipRater examines the Package as well as the BoxType, and returns a list of possible shipping rates/methods.
What I would like to do is construct an Interface, IRateable, that would be supplied to the helper class ShipRater. So instead of:
Class ShipRater
Sub New(SomePackage as Package)
End Sub
End Class
we would do:
Class ShipRater
Sub New(SomePackage as IRateable)
End Sub
End Class
However, ShipRater requires information from both the Package and its aggregate, BoxType. If I write an interface IRateable, then how can I use the BoxType properties to implement part of the Interface? Is this possible?