Skip to content

Instantly share code, notes, and snippets.

@bergpb
Last active April 11, 2020 22:19
Show Gist options
  • Select an option

  • Save bergpb/00d9f1b9609200408c2ffdf0914e4a99 to your computer and use it in GitHub Desktop.

Select an option

Save bergpb/00d9f1b9609200408c2ffdf0914e4a99 to your computer and use it in GitHub Desktop.
Gerenciamento de Estados com Python
# 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"
@bergpb

bergpb commented Apr 11, 2020

Copy link
Copy Markdown
Author

python -i state.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment