1
This commit is contained in:
2024-11-30 22:07:38 +08:00
parent 4142bd9423
commit ee8bf46701
8 changed files with 219 additions and 29 deletions

View File

@@ -0,0 +1,20 @@
class MahjongTile:
SUITS = ['', '', '']
def __init__(self, suit, value):
if suit not in self.SUITS or not (1 <= value <= 9):
raise ValueError("Invalid tile")
self.suit = suit
self.value = value
def __repr__(self):
return f"{self.value}{self.suit}"
def __eq__(self, other):
return self.suit == other.suit and self.value == other.value
def __hash__(self):
return hash((self.suit, self.value))