Can an interface be implemented across an aggregate/composite class in vb.net?
Posted
by Casey
on Stack Overflow
See other posts from Stack Overflow
or by Casey
Published on 2010-03-30T14:01:10Z
Indexed on
2010/03/30
14:03 UTC
Read the original article
Hit count: 464
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?
© Stack Overflow or respective owner