Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Card:
- suits = ["spades", "hearts", "diamonds", "clubs"]
- values = [None, None, "2", "3", "4", "5", "6", "7", "8", "9",
- "10", "Jack", "Queen", "King", "Ace"]
- def __init__(self, v, s):
- """スートも値も整数値です。"""
- self.value = v
- self.suit = s
- def __lt__(self, c2):
- if self.value < c2.value:
- return True
- if self.value == c2.value:
- if self.suit < c2.suit:
- return True
- else:
- return False
- return False
- >>> c1 = Card(4, 1)
- >>> c2 = Card(5, 2)
- >>> c1 < c2
- True
Add Comment
Please, Sign In to add comment