I have a Object say Car which has different methods to get Cars of different car makers e.g. Audi, BMW, Merc etc. All these car classes do not have any common interface or abstract classes on them but have some common properties as wheel, brakes etc. Car object has a method to identify which type of maker object should be used to extract properties. Can anyone suggest me a good approach to extract wheels from car object?
public class Car {
public Audi getAudi() { return this.audi; }
public BMW getBMW() { return this.bmw; }
public Merc getMerc() { return this.merc; )
public String getMaker() { return this.maker; }
}
public class Audi {
public Wheel getWheel() { return this.wheel; }
public Brakes getBrakes() { return this.brakes; }
}
public class BMW {
public Wheel getWheel() { return this.wheel; }
public Brakes getBrakes() { return this.brakes; }
}
public class Merc{
public Wheel getWheel() { return this.wheel; }
public Brakes getBrakes() { return this.brakes; }
}