Question:

> 
> Class SmartPhone, given below, violates the rule on encapsulation.
>  Re-write it so that encapsulation is preserved.
> 
> 
> 

```
class Battery{
    private String type;
    private int voltage;
    public Battery(String t, int v){type = t; voltage = v}
    public String getType(){return type;}
    public int getVoltage(){return voltage;} 
    public void setType(String t){type = t;}
    public void setVoltage(int v){voltage = v;}
}

class SmartPhone {
    private Battery battery;
    private String make, model;
    public SmartPhone(String make, String model, Battery battery){
        this.make = make; this.model = model;
        this.battery = battery;
    }
    public String getMake(){return make;} 
    public String getModel(){return model;}

    //I think here it is breaking encapsulation
    public Battery getBattery(){return battery;}
}

```

I can not see any other rules breaking encapsulation, I can not rember why this is breaking it.

Is it because we are returning an instance of another class from outside that class in this example its`battery` hence breaking encapsulation?