Last active
April 11, 2020 22:19
-
-
Save bergpb/00d9f1b9609200408c2ffdf0914e4a99 to your computer and use it in GitHub Desktop.
Gerenciamento de Estados com Python
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
| # https://www.youtube.com/watch?v=QXorM9jsBNo | |
| import time | |
| class Main: | |
| def __init__(self) -> None: | |
| self.state = False | |
| class Tv: | |
| def __init__(self) -> None: | |
| super().__init__() | |
| def ligar(self): | |
| print("A tv está sendo ligada") | |
| sleep(2) | |
| self.state = True | |
| def desligar(self): | |
| print("A tv está sendo desligada") | |
| sleep(2) | |
| self.state = False | |
| def status(self): | |
| if self.state: | |
| return "A tv está ligada" | |
| return "A tv está desligada" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python -i state.py