I have a question on VB.Net Inheritance. I am building a security pricing engine. Suppose I have a base class and multiple sub-classes. Each subclass has its own pricing methodology but the sensitivity calculation is all the same among all the subclasses. I am having a hard time to write the code since the "RateSensitivity" as an example should be in the common class but the price calculation is in all the subclasses. How should I structure the classes?
Public Class Common Public Maturity as double Public Function RateSensitivity(Market as double) RateSensitivity = (Price(Market+1) +Price(Market-1))/2 End Function End Class Public Class SecurityA inherits Common Public Maturity as double '.....(different kinds of attributes) Public Function Price(Market as double) Price = Market^2 End function End Class Public Class SecurityB inherits Common Public Maturity as double '.....(different kinds of attributes) Public Function Price(Market as double) Price = log(Market^2) End function End Class
Last edited by a moderator: