carro 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- carro-0.1.0/LICENSE +21 -0
- carro-0.1.0/PKG-INFO +11 -0
- carro-0.1.0/README.md +1 -0
- carro-0.1.0/pyproject.toml +13 -0
- carro-0.1.0/setup.cfg +4 -0
- carro-0.1.0/src/carro/__init__.py +79 -0
- carro-0.1.0/src/carro.egg-info/PKG-INFO +11 -0
- carro-0.1.0/src/carro.egg-info/SOURCES.txt +10 -0
- carro-0.1.0/src/carro.egg-info/dependency_links.txt +1 -0
- carro-0.1.0/src/carro.egg-info/entry_points.txt +2 -0
- carro-0.1.0/src/carro.egg-info/requires.txt +1 -0
- carro-0.1.0/src/carro.egg-info/top_level.txt +1 -0
carro-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 eduardozitinho1
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
carro-0.1.0/PKG-INFO
ADDED
carro-0.1.0/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# carro
|
carro-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
import typer
|
|
3
|
+
|
|
4
|
+
app = typer.Typer()
|
|
5
|
+
|
|
6
|
+
class Car:
|
|
7
|
+
"""
|
|
8
|
+
Classe principal do carro
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self):
|
|
12
|
+
self._speed = 0
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def speed(self):
|
|
16
|
+
return self._speed
|
|
17
|
+
|
|
18
|
+
@speed.setter
|
|
19
|
+
def speed(self, speed):
|
|
20
|
+
if speed > 150:
|
|
21
|
+
raise ValueError("Velocidade do carro é muito grande, o carro pode quebrar")
|
|
22
|
+
elif speed < -50:
|
|
23
|
+
raise ValueError("O carro não tem potência o suficiente para ir muito para trás")
|
|
24
|
+
else:
|
|
25
|
+
self._speed = speed
|
|
26
|
+
|
|
27
|
+
def running(self):
|
|
28
|
+
return self.speed != 0
|
|
29
|
+
|
|
30
|
+
def accelerate(self, speed):
|
|
31
|
+
try:
|
|
32
|
+
self.speed += speed
|
|
33
|
+
print(f"Carro acelerou {speed}km/h! Agora ele está a {self.speed}km/h")
|
|
34
|
+
except ValueError:
|
|
35
|
+
print("Velocidade do carro é muito grande, o carro pode quebrar")
|
|
36
|
+
|
|
37
|
+
def decelerate(self, speed):
|
|
38
|
+
try:
|
|
39
|
+
self.speed -= speed
|
|
40
|
+
print(f"Carro desacelerou {speed}km/h! Agora ele está a {self.speed}km/h")
|
|
41
|
+
except ValueError:
|
|
42
|
+
print("O carro não tem potência o suficiente para ir muito para trás")
|
|
43
|
+
|
|
44
|
+
def stop(self):
|
|
45
|
+
if not self.running():
|
|
46
|
+
print("Já está parado")
|
|
47
|
+
else:
|
|
48
|
+
self.speed = 0
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
carro = Car()
|
|
52
|
+
|
|
53
|
+
@app.command
|
|
54
|
+
def main():
|
|
55
|
+
while True:
|
|
56
|
+
opt = input("O que deseja fazer com o carro atualmente? (digite \"s\" para sair)\n1. Ver velocidade atual\n2. Acelerar\n3. Desacelerar\n4. Parar\n> ")
|
|
57
|
+
match opt:
|
|
58
|
+
case "1":
|
|
59
|
+
print(f"A velocidade atual do seu carro é de {carro.speed}km/h")
|
|
60
|
+
case "2":
|
|
61
|
+
speed = Decimal(
|
|
62
|
+
input("Quanto é a quantidade que você quer acelerar? (Em km/h): ")
|
|
63
|
+
)
|
|
64
|
+
carro.accelerate(speed)
|
|
65
|
+
case "3":
|
|
66
|
+
speed = Decimal(
|
|
67
|
+
input("Quanto é a quantidade que você quer desacelerar? (Em km/h): ")
|
|
68
|
+
)
|
|
69
|
+
carro.decelerate(speed)
|
|
70
|
+
case "4":
|
|
71
|
+
carro.stop()
|
|
72
|
+
case "s":
|
|
73
|
+
break
|
|
74
|
+
case _:
|
|
75
|
+
print("Opção inválida")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
main()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/carro/__init__.py
|
|
5
|
+
src/carro.egg-info/PKG-INFO
|
|
6
|
+
src/carro.egg-info/SOURCES.txt
|
|
7
|
+
src/carro.egg-info/dependency_links.txt
|
|
8
|
+
src/carro.egg-info/entry_points.txt
|
|
9
|
+
src/carro.egg-info/requires.txt
|
|
10
|
+
src/carro.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
typer>=0.27.2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
carro
|