Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Sousa-Amorim authored Apr 15, 2024
1 parent 04afeaf commit c435a5b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Conteúdo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,41 @@ class Baralho:
print(len(self.baralho))
```

### Exercício 10 📝

```python
"""
Implemente operadores sobrecarregados repr() e == para a classe Card. Sua nova classe Card deverá se comportar como a seguir:
>>> Card('3', '♠') == Card('3', '♠')
True
>>> Card('3', '♠') == eval(repr(Card('3', '♠')))
True
"""

class Card:
'representa uma Card do jogo'
def __init__(self, value:str, naipe:str):
'inicializa valor e naipe da Card do jogo'
self.value = value
self.suit = naipe
def getRank(self):
'retorna valor'
return self.valor
def getSuit(self):
'retorna naipe'
return self.naipe
def __eq__(self, other):
return self.value == other.value and self.suit == other.suit
def __repr__(self):
return f"Card('{self.value}', '{self.suit}')"

print(Card('3', '') == Card('3', ''))
print(Card('3', '') == eval(repr(Card('3', ''))))
```

### Exercício 10 📝
### Exercício 11 📝
Expand Down

0 comments on commit c435a5b

Please sign in to comment.