The first idea that came to mind was for your Car class to implement 3 different interfaces that every other class can use to interact with your Car class.
For example, (and my names can be improved, but you should get this idea), the IDriverAccess interface could be as follows:
public interface IDriverAccess { double Mileage { get; } }
The IMechanicAccess interface may be as follows:
public interface IMechanicAccess { EngineObject Engine { get; set; } double Mileage { get; } }
And so on. Then your car class can implement these interfaces, but the classes for the driver, mechanic, and passenger will simply use the interfaces to interact with the object.
public Car : IDriverAccess, IMechanicAccess, IPassengerAccess {
Eric Olsson
source share