I was wondering how one can conditionally hide data in class. For instance , lets say I have a class called Car which has three fields : Engine , MeterReading and Mileage.
I have three other entities called : Driver , Mechanic and Passenger. Now what I want is that :
A Driver should only be able to access Mileage ( and not Engine and MeterReading)
A Mechanic should only be able to access Engine and Mileage( and not MeterReading)
A Passenger should only be able to access MeterReading ( and not Engine and Mileage )
What could be the best way to implement this ..( without basing the whole logic on if else statements ) ?
Any ideas guys ?
Thanks.