Added a method to Card.py

This commit is contained in:
2026-02-10 18:39:13 -05:00
parent d491874a3d
commit 3382b922ab

View File

@@ -20,3 +20,12 @@ class Card:
return f"{self._value} of {self._suit}" return f"{self._value} of {self._suit}"
#Returns a string representation of the card in the format "Value of Suit". #Returns a string representation of the card in the format "Value of Suit".
def __add__(self, other) -> int:
if isinstance(other, Card):
return self.value + other.value
elif isinstance(other, int):
return self.value + other
else:
return NotImplemented
#Added for project 2: Created an "__add__" meathod to allow adding Cards together.