I have an Object I want to modify.
I'd like to put a wrapper class around it.
so I can keep the current object + just modify the data returned from it.
Say I have a Car Object and I want to create a Pimped wrapper class.
I can make a PimpedCar Class that extends Car and takes the original Car as a param in its constructor.
public class CarPimper extends Car{
private Car carToPimp;
public PimpedCar( Car car){carToPimp = car;}
public Image getImage( ){
Image carImage = carToPimp.getImage();
addSpeedStripes( carImage );
return carImage;
}
public int getNumWheels( ){return carToPimp.getNumWheels();}
private void addSpeedStripes( Image image){
//whatevers needed
}
}
To code this way I have to override every method in Car and eithor just return the data from the same method for carToPimp or adapt the data before I return it.
This is all very well except that some of the methods I want to override + call are final. So I can't override them.
I guess it's poor that my Car Object is not an interface, but thats somthing that I can't change.
So I'm stuck - is there any other way for me to do this?