diff --git a/oo/__init__.py b/oo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/oo/carro.py b/oo/carro.py new file mode 100644 index 000000000..2e845b64a --- /dev/null +++ b/oo/carro.py @@ -0,0 +1,150 @@ +""" +Você deve criar uma classe carro que vai possuir +dois atributos compostos por outras duas classes: + +Motor +Direção +O Motor terá a responsabilidade de controlar a velocidade. +Ele oferece os seguintes atributos: + +Atributo de dado velocidade +Método acelerar, que deverá incremetar a velocidade de uma unidade +Método frear que deverá decrementar a velocidade em duas unidades +A Direção terá a responsabilidade de controlar a direção. Ela oferece +os seguintes atributos: + +Valor de diração com valores possíveis: Norte, Sul, Leste, Oeste. +Método girar_a_direita +Método girar_a_esquerda + + N + O L + S + +Exemplo: + >>> # Testando motor + >>> motor = Motor() + >>> motor.velocidade + 0 + >>> motor.acelerar() + >>> motor.velocidade + 1 + >>> motor.acelerar() + >>> motor.velocidade + 2 + >>> motor.acelerar() + >>> motor.velocidade + 3 + >>> motor.frear() + >>> motor.velocidade + 1 + >>> motor.frear() + >>> motor.velocidade + 0 + >>> # Testando Direcao + >>> direcao = Direcao() + >>> direcao.valor + 'Norte' + >>> direcao.girar_a_direita() + >>> direcao.valor + 'Leste' + >>> direcao.girar_a_direita() + >>> direcao.valor + 'Sul' + >>> direcao.girar_a_direita() + >>> direcao.valor + 'Oeste' + >>> direcao.girar_a_direita() + >>> direcao.valor + 'Norte' + >>> direcao.girar_a_esquerda() + >>> direcao.valor + 'Oeste' + >>> direcao.girar_a_esquerda() + >>> direcao.valor + 'Sul' + >>> direcao.girar_a_esquerda() + >>> direcao.valor + 'Leste' + >>> direcao.girar_a_esquerda() + >>> direcao.valor + 'Norte' + >>> carro = Carro(direcao, motor) + >>> carro.calcular_velocidade() + 0 + >>> carro.acelerar() + >>> carro.calcular_velocidade() + 1 + >>> carro.acelerar() + >>> carro.calcular_velocidade() + 2 + >>> carro.frear() + >>> carro.calcular_velocidade() + 0 + >>> carro.calcular_direcao() + 'Norte' + >>> carro.girar_a_direita() + >>> carro.calcular_direcao() + 'Leste' + >>> carro.girar_a_esquerda() + >>> carro.calcular_direcao() + 'Norte' + >>> carro.girar_a_esquerda() + >>> carro.calcular_direcao() + 'Oeste' +""" + + +class Motor: + def __init__(self): + self.velocidade = 0 + + def acelerar(self): + self.velocidade += 1 + + def frear(self): + self.velocidade -= 2 + self.velocidade = max(0, self.velocidade) + +NORTE = 'Norte' +SUL = 'Sul' +LESTE = 'Leste' +OESTE = 'Oeste' + +class Direcao: + + rotacao_a_direita_dct = {NORTE: LESTE, LESTE: SUL, SUL: OESTE, OESTE: NORTE} + rotacao_a_esquerda_dct = {NORTE: OESTE, OESTE: SUL, SUL: LESTE, LESTE: NORTE} + + def __init__(self): + self.valor = NORTE + + def girar_a_esquerda(self): + self.valor = self.rotacao_a_esquerda_dct[self.valor] + + def girar_a_direita(self): + self.valor = self.rotacao_a_direita_dct[self.valor] + + +class Carro: + def __init__(self, direcao, motor): + self.motor = motor + self.direcao = direcao + + def calcular_velocidade(self): + return self.motor.velocidade + + def acelerar(self): + self.motor.acelerar() + + def frear(self): + self.motor.frear() + + def calcular_direcao(self): + return self.direcao.valor + + def girar_a_direita(self): + self.direcao.girar_a_direita() + + def girar_a_esquerda(self): + self.direcao.girar_a_esquerda() diff --git a/oo/pessoa.py b/oo/pessoa.py new file mode 100644 index 000000000..83323568f --- /dev/null +++ b/oo/pessoa.py @@ -0,0 +1,33 @@ +class Pessoa: + olhos = 3 + + def __init__(self, *filhos, nome = None, idade = 35): + self.nome = nome + self.idade = idade + self.filhos = list(filhos) + + + def cumprimentar(self): + return "Olá" + + @staticmethod + def metodo_estatico(): + return 42 + + @classmethod + def nome_e_atributos_de_classe(cls): + return f'{cls} - olhos: {cls.olhos}' + +if __name__ == '__main__': + douglas = Pessoa(nome="Douglas") + edson = Pessoa(douglas, nome="Edson") + + for filho in edson.filhos: + print(filho.nome) + + edson.sobrenome = "Souza de Almeida" + print(douglas.__dict__) + print(edson.__dict__) + + print(douglas.metodo_estatico()) + print(Pessoa.nome_e_atributos_de_classe()) \ No newline at end of file diff --git a/venv/Scripts/Activate.ps1 b/venv/Scripts/Activate.ps1 new file mode 100644 index 000000000..6d5870851 --- /dev/null +++ b/venv/Scripts/Activate.ps1 @@ -0,0 +1,51 @@ +function global:deactivate ([switch]$NonDestructive) { + # Revert to original values + if (Test-Path function:_OLD_VIRTUAL_PROMPT) { + copy-item function:_OLD_VIRTUAL_PROMPT function:prompt + remove-item function:_OLD_VIRTUAL_PROMPT + } + + if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) { + copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME + remove-item env:_OLD_VIRTUAL_PYTHONHOME + } + + if (Test-Path env:_OLD_VIRTUAL_PATH) { + copy-item env:_OLD_VIRTUAL_PATH env:PATH + remove-item env:_OLD_VIRTUAL_PATH + } + + if (Test-Path env:VIRTUAL_ENV) { + remove-item env:VIRTUAL_ENV + } + + if (!$NonDestructive) { + # Self destruct! + remove-item function:deactivate + } +} + +deactivate -nondestructive + +$env:VIRTUAL_ENV="C:\Users\dougl\PycharmProjects\pythonbirds\venv" + +if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) { + # Set the prompt to include the env name + # Make sure _OLD_VIRTUAL_PROMPT is global + function global:_OLD_VIRTUAL_PROMPT {""} + copy-item function:prompt function:_OLD_VIRTUAL_PROMPT + function global:prompt { + Write-Host -NoNewline -ForegroundColor Green '(venv) ' + _OLD_VIRTUAL_PROMPT + } +} + +# Clear PYTHONHOME +if (Test-Path env:PYTHONHOME) { + copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME + remove-item env:PYTHONHOME +} + +# Add the venv to the PATH +copy-item env:PATH env:_OLD_VIRTUAL_PATH +$env:PATH = "$env:VIRTUAL_ENV\Scripts;$env:PATH" diff --git a/venv/Scripts/activate b/venv/Scripts/activate new file mode 100644 index 000000000..e4b8cd107 --- /dev/null +++ b/venv/Scripts/activate @@ -0,0 +1,76 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then + PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "$1" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="C:\Users\dougl\PycharmProjects\pythonbirds\venv" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/Scripts:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "${PYTHONHOME:-}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + if [ "x(venv) " != x ] ; then + PS1="(venv) ${PS1:-}" + else + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" + else + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" + fi + fi + export PS1 +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r +fi diff --git a/venv/Scripts/activate.bat b/venv/Scripts/activate.bat new file mode 100644 index 000000000..aa54f9b5d --- /dev/null +++ b/venv/Scripts/activate.bat @@ -0,0 +1,32 @@ +@echo off +set "VIRTUAL_ENV=C:\Users\dougl\PycharmProjects\pythonbirds\venv" + +if not defined PROMPT ( + set "PROMPT=$P$G" +) + +if defined _OLD_VIRTUAL_PROMPT ( + set "PROMPT=%_OLD_VIRTUAL_PROMPT%" +) + +if defined _OLD_VIRTUAL_PYTHONHOME ( + set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%" +) + +set "_OLD_VIRTUAL_PROMPT=%PROMPT%" +set "PROMPT=(venv) %PROMPT%" + +if defined PYTHONHOME ( + set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" + set PYTHONHOME= +) + +if defined _OLD_VIRTUAL_PATH ( + set "PATH=%_OLD_VIRTUAL_PATH%" +) else ( + set "_OLD_VIRTUAL_PATH=%PATH%" +) + +set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%" + +:END diff --git a/venv/Scripts/deactivate.bat b/venv/Scripts/deactivate.bat new file mode 100644 index 000000000..1205c6186 --- /dev/null +++ b/venv/Scripts/deactivate.bat @@ -0,0 +1,21 @@ +@echo off + +if defined _OLD_VIRTUAL_PROMPT ( + set "PROMPT=%_OLD_VIRTUAL_PROMPT%" +) +set _OLD_VIRTUAL_PROMPT= + +if defined _OLD_VIRTUAL_PYTHONHOME ( + set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%" + set _OLD_VIRTUAL_PYTHONHOME= +) + +if defined _OLD_VIRTUAL_PATH ( + set "PATH=%_OLD_VIRTUAL_PATH%" +) + +set _OLD_VIRTUAL_PATH= + +set VIRTUAL_ENV= + +:END diff --git a/venv/Scripts/easy_install-3.6.exe b/venv/Scripts/easy_install-3.6.exe new file mode 100644 index 000000000..d99e05065 Binary files /dev/null and b/venv/Scripts/easy_install-3.6.exe differ diff --git a/venv/Scripts/easy_install.exe b/venv/Scripts/easy_install.exe new file mode 100644 index 000000000..d99e05065 Binary files /dev/null and b/venv/Scripts/easy_install.exe differ diff --git a/venv/Scripts/pip.exe b/venv/Scripts/pip.exe new file mode 100644 index 000000000..d25105d1e Binary files /dev/null and b/venv/Scripts/pip.exe differ diff --git a/venv/Scripts/pip3.6.exe b/venv/Scripts/pip3.6.exe new file mode 100644 index 000000000..d25105d1e Binary files /dev/null and b/venv/Scripts/pip3.6.exe differ diff --git a/venv/Scripts/pip3.exe b/venv/Scripts/pip3.exe new file mode 100644 index 000000000..d25105d1e Binary files /dev/null and b/venv/Scripts/pip3.exe differ diff --git a/venv/Scripts/python.exe b/venv/Scripts/python.exe new file mode 100644 index 000000000..0d3612790 Binary files /dev/null and b/venv/Scripts/python.exe differ diff --git a/venv/Scripts/python3.dll b/venv/Scripts/python3.dll new file mode 100644 index 000000000..f70f47e2a Binary files /dev/null and b/venv/Scripts/python3.dll differ diff --git a/venv/Scripts/python36.dll b/venv/Scripts/python36.dll new file mode 100644 index 000000000..fc80678f4 Binary files /dev/null and b/venv/Scripts/python36.dll differ diff --git a/venv/Scripts/pythonw.exe b/venv/Scripts/pythonw.exe new file mode 100644 index 000000000..ad4e29e66 Binary files /dev/null and b/venv/Scripts/pythonw.exe differ diff --git a/venv/Scripts/sqlite3.dll b/venv/Scripts/sqlite3.dll new file mode 100644 index 000000000..a8a7c9bb3 Binary files /dev/null and b/venv/Scripts/sqlite3.dll differ diff --git a/venv/Scripts/tcl86t.dll b/venv/Scripts/tcl86t.dll new file mode 100644 index 000000000..2ed88d0cf Binary files /dev/null and b/venv/Scripts/tcl86t.dll differ diff --git a/venv/Scripts/tk86t.dll b/venv/Scripts/tk86t.dll new file mode 100644 index 000000000..1b72d6672 Binary files /dev/null and b/venv/Scripts/tk86t.dll differ diff --git a/venv/Scripts/vcruntime140.dll b/venv/Scripts/vcruntime140.dll new file mode 100644 index 000000000..52fe06bd6 Binary files /dev/null and b/venv/Scripts/vcruntime140.dll differ diff --git a/venv/pyvenv.cfg b/venv/pyvenv.cfg new file mode 100644 index 000000000..be9a3e83b --- /dev/null +++ b/venv/pyvenv.cfg @@ -0,0 +1,3 @@ +home = C:\Users\dougl\AppData\Local\Programs\Python\Python36 +include-system-site-packages = false +version = 3.6.4