added Card class

This commit is contained in:
2025-10-26 19:37:38 +01:00
parent 97c0ca75ea
commit 388a4563c3

24
src/pyjack/card.py Normal file
View File

@@ -0,0 +1,24 @@
class Card:
"""Class to represent an single card of a full deck"""
# TODO: - write tests
def __init__(self, suit: str, rank: str) -> None:
"""Initializes the card and calculating its value"""
self.suit = suit
self.rank = rank
# determine the initial card value
if rank == "J" or rank == "Q" or rank == "K":
self.value = 10
elif rank == "A":
self.value = 11
else:
self.value = int(rank)
def __str__(self) -> str:
return self.rank + " of " + self.suit
def get_value(self) -> int:
"""Returns the value of the card"""
return self.value