understanding encapsulation and inheritance