1 - Python - Encapsulation
1 - Python - Encapsulation
class Car:
def __init__(self, make, model):
self.make = make # Public member
self.model = model # Public member
def display_info(self):
print(f"Car make: {self.make}")
print(f"Car model: {self.model}")
def display_balance(self):
print(f"Account Balance: ${self.__balance}")
def display_details(self):
print(f"Name: {self._name}")
print(f"Salary: ${self._salary}")
Python will warn you that you are using a protected attribute which you shouldnt