Skip to content

Commit b8edd43

Browse files
author
renzon
committed
Teste de lançamento de pássaros
1 parent a672878 commit b8edd43

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

fase.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
from atores import ATIVO
22

33

4+
class Ponto():
5+
def __init__(self, x, y, caracter):
6+
self.caracter = caracter
7+
self.x = x
8+
self.y = y
9+
10+
def __eq__(self, other):
11+
return self.x == other.x and self.y == other.y and self.caracter == other.caracter
12+
13+
414
class Fase():
515
def __init__(self):
616
self._passaros = []
@@ -19,7 +29,7 @@ def adicionar_passaro(self, *passaros):
1929
def acabou(self, tempo):
2030
return not self._existe_porco_ativo(tempo) or not self._existe_passaro_ativo(tempo)
2131

22-
def status(self,tempo):
32+
def status(self, tempo):
2333
if self._existe_passaro_ativo(tempo):
2434
return 'Jogo em andamento.'
2535
if self._existe_porco_ativo(tempo):
@@ -36,6 +46,6 @@ def _verificar_se_existe_ator_ativo(self, atores, tempo):
3646
return False
3747

3848
def _existe_passaro_ativo(self, tempo):
39-
return self._verificar_se_existe_ator_ativo(self._passaros,tempo)
49+
return self._verificar_se_existe_ator_ativo(self._passaros, tempo)
4050

4151

testes/fase_testes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,25 @@ def teste_status(self):
100100
self.assertEqual('Jogo em andamento.', fase.status(3),
101101
'Com Porco ativo e com pássaro para lançar, o jogo não deveria acabar')
102102

103+
def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
104+
fase = Fase()
105+
fase.lancar(90, 0)
106+
107+
def teste_lancar_passaro_sem_erro_quando_nao_existe_passaro(self):
108+
passaro_vermelho, passaro_amarelo = PassaroVermelho(1, 1), PassaroAmarelo(1, 1)
109+
fase = Fase(passaro_vermelho, passaro_amarelo)
110+
fase.lancar(90, 1)
111+
fase.lancar(45, 3)
112+
fase.lancar(31, 5) # testando que lançar passaros depos de todos lançados não causa erro
113+
self.assertEqual(90, passaro_vermelho._angulo_de_lancamento)
114+
self.assertEqual(1, passaro_vermelho._tempo_de_lancamento)
115+
116+
self.assertEqual(45, passaro_amarelo._angulo_de_lancamento)
117+
self.assertEqual(3, passaro_amarelo._tempo_de_lancamento)
118+
119+
120+
# def teste_calcular_pontos(self):
121+
# fase=Fase()
122+
# self.assertListEqual([],fase.calcular)
123+
103124

0 commit comments

Comments
 (0)