Skip to content

Commit b08e0aa

Browse files
committed
Remove unnecessary properties and setters
1 parent 35e2d42 commit b08e0aa

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

comportamentais/memento/main.py

+14-40
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,29 @@
33

44
class Contrato:
55
def __init__(self, data, cliente, tipo):
6-
self.__data = data
7-
self.__cliente = cliente
8-
self.__tipo = tipo
9-
10-
@property
11-
def data(self):
12-
return self.__data
13-
14-
@data.setter
15-
def data(self, data):
16-
self.__data = data
17-
18-
@property
19-
def cliente(self):
20-
return self.__cliente
21-
22-
@cliente.setter
23-
def cliente(self, cliente):
24-
self.__cliente = cliente
25-
26-
@property
27-
def tipo(self):
28-
return self.__tipo
29-
30-
@tipo.setter
31-
def tipo(self, tipo):
32-
self.__tipo = tipo
6+
self.data = data
7+
self.cliente = cliente
8+
self.tipo = tipo
339

3410
def avanca(self):
35-
if self.__tipo == "NOVO":
36-
self.__tipo = "EM ANDAMENTO"
37-
elif self.__tipo == "EM ANDAMENTO":
38-
self.__tipo = "ACERTADO"
39-
elif self.__tipo == "ACERTADO":
40-
self.__tipo = "CONCLUIDO"
11+
if self.tipo == "NOVO":
12+
self.tipo = "EM ANDAMENTO"
13+
elif self.tipo == "EM ANDAMENTO":
14+
self.tipo = "ACERTADO"
15+
elif self.tipo == "ACERTADO":
16+
self.tipo = "CONCLUIDO"
4117

4218
def salva_estado(self):
4319
# Não podemos passar o self para o Estado pois se o contrato fosse
44-
# alterado o estado anterior dele tambem seria alterado
20+
# alterado o estado anterior dele também seria alterado
4521
return Estado(
46-
Contrato(
47-
data=self.__data, cliente=self.__cliente, tipo=self.__tipo
48-
)
22+
Contrato(data=self.data, cliente=self.cliente, tipo=self.tipo)
4923
)
5024

5125
def restaura_estado(self, estado):
52-
self.__cliente = estado.contrato.cliente
53-
self.__data = estado.contrato.data
54-
self.__tipo = estado.contrato.tipo
26+
self.cliente = estado.contrato.cliente
27+
self.data = estado.contrato.data
28+
self.tipo = estado.contrato.tipo
5529

5630

5731
class Estado:

criacao/monostate/main.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class Monostate:
55
def __init__(self):
66
self.x = 1
77
self.__dict__ = self.__shared_state
8-
pass
98

109

1110
if __name__ == "__main__":

0 commit comments

Comments
 (0)