Encapsulation is one of the 4 main OOP principles.
It protects the class data from access outside the class body.
Members that are supposed to be accessed only in the class
are labeled with __
prefix.
Result:
Explanation:
__model
and __manifactureYear
)
are supposed to be accessed / modified by
functions defined inside the class (in this case getters and setters).
Output:
All members are accessed outside the class body.