Created
October 1, 2018 16:57
-
-
Save JackInTaiwan/16d344a34f9fd6e3ef086dc77fd26d10 to your computer and use it in GitHub Desktop.
python_advanced_private_3
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 Animal: | |
def __init__(self): | |
self.__alive = True | |
self.__age = 0 | |
def get_age(self): | |
return self.__age | |
def add_age(self): | |
self.__age += 1 | |
dog = Animal() | |
print(dog.get_age()) | |
# 0 | |
dog.add_age() | |
print(dog.get_age()) | |
# 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment