-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses_poo.py
More file actions
37 lines (26 loc) · 952 Bytes
/
classes_poo.py
File metadata and controls
37 lines (26 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Carrinho:
def __init__(self, seats, color, engine, fuel_capacity):
self.seats = seats
self.color = color
self.engine = engine
self.fuel_capacity = fuel_capacity
self.mileage = 0
self.use_historic = []
self.eficience = 0.0
def enter_race_mode(self):
self.seats = 2
self.engine = 1.8
self.fuel_capacity = 55
def viajar(self, origem, destino, miles, used_fuel):
self.use_historic.append([origem, destino, miles, used_fuel])
self.mileage += miles
if self.eficience > 0:
self.eficience = (self.eficience + (miles / used_fuel)) / 2
else:
self.eficience = miles / used_fuel
uno = Carrinho(5,'Verde',1.0,45)
uno.viajar('Morungaba', 'Campinas', 52, 10)
uno.viajar('Campinas', 'Curitiba', 498, 10)
print(uno.use_historic)
print(uno.mileage)
print(uno.eficience)