Question: I have an Object which comes and has a bunch of public attributes and no getters and setters. BAD! 
So I created a class with the attributes and created getters and setters for them. My plan is to wrap the object in my class so it means no direct access to attributes.
I'm kind of unsure how to do this. I understand casting fine.
How exactly could I wrap the class with my safe class with getters and setters and gain access to the attributes via my getters and setters?

Answer: 
Maybe like this?

```
class MyCar implements ICar{

    private final Car car;
    public MyCar(Car car)
    {
         this.car = car;
    }

    public string getModel()
    {
          return car.model;
    }

    public void setModel(string value)
    {
          car.model = value;
    }

}

```

now instead of passing around an instance of `Car`, you can either pass around `MyCar` instance which has getters and setters or a reference to `ICar` which will let you control exactly what you would like to expose (for example you could just expose the getters).
If you want your class to be plug-compatible with the original class (meaning that client code does not need to change variable types), then your class will have to be a subclass of the class that the client code expects. In that case, you cannot hide the public variables, although you can easily add getters and setters. Even if you subclass, however, that won't help if the original class has other subclasses; they won't see those getters and setters.

If you can introduce an unrelated class, then the solution is to delegate everything:

```
public class BetterThing {
    private Thing thing;
    public BetterThing(Thing thing) {
        this.thing = thing;
    }
    public int getIntProperty1() {
        return thing.property1;
    }
    public void setIntProperty1(int value) {
        thing.property1 = value;
    }
    // etc.
}

```