Hey there !!
I am trying to design a web portal for auto/car dealer. When customer searches for a vehicle, they can show their "like" and "contact" a sales person for their area.
My client sells different vehicles - cars, two wheeler as of now. While building this I want to make save of data in a generic fashion. So I am thinking of pattern for program to interface rather than concrete class. In this case, I will have a class Vehicle which will implement IVehicle interface which will have some properties as well methods. Vehicle will be base class for Car and Motorcycle. Now when I call method like Save, I would like to pass IVehicle as input rather than Car or Motorcycle as input so that I can access generic properties. However there will also be some specific properties in Car and Motorcycle - like in example below, how would I access those specific properties if I use this pattern of interfaces. Example in code section below.
Public VehicleType As String()
Public Color As String()
Class Vehicle Implements IVehicle
Public VehicleType As String() Implments IVehicle.VehicleType
Public Color As String() Implments IVehicle.Color
Class Car Inherits Vehicle
Public Property IsHatchback As Boolean
Class Motorcycle Inherits Vehicle
Public Property HasFootPedal As Boolean
Public Sub Save(input As IVehicle)
If Car then Console.WriteLine(input.IsHatchBack)
If Motorcycle Console.WriteLine(input.HasFootPedal)