Created
September 13, 2018 22:20
-
-
Save pknowledge/f494086109fd51043c36449995517314 to your computer and use it in GitHub Desktop.
car_Encapsulation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car: | |
def __init__(self, speed, color): | |
self.__speed = speed | |
self.__color = color | |
def set_speed(self, value): | |
self.__speed = value | |
def get_speed(self): | |
return self.__speed | |
def set_color(self, value): | |
self.__color = value | |
def get_color(self): | |
return self.__color | |
ford = Car(200, 'red') | |
honda = Car(250, 'blue') | |
audi = Car(300, 'black') | |
ford.set_speed(300) | |
print(ford.get_speed()) | |
print(ford.get_color()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment