Created
February 26, 2015 16:42
-
-
Save moisesnandres/5b372a9a359b6b9f99a6 to your computer and use it in GitHub Desktop.
Encapsulamiento
This file contains hidden or 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 Televisor(object): | |
... def __init__(self,marca): | |
... self.__marca = marca | |
... self.encendido = False | |
... def encenderT(self): | |
... if self.encendido == False: | |
... self.encendido = True | |
... else: | |
... print "El televisor ya estaba encendido" | |
... def apagarT(self): | |
... if self.encendido == True: | |
... self.encendido = False | |
... else: | |
... print "El televisor ya estaba apagado" | |
... | |
>>> tele = Televisor("LG") | |
>>> print tele.encenderT() | |
El televisor ya estaba encendido | |
>>> print tele.__marca() | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: 'Televisor' object has no attribute '__marca' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment