Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. class Card:
  2. suits = ["spades", "hearts", "diamonds", "clubs"]
  3.  
  4. values = [None, None, "2", "3", "4", "5", "6", "7", "8", "9",
  5. "10", "Jack", "Queen", "King", "Ace"]
  6.  
  7. def __init__(self, v, s):
  8. """スートも値も整数値です。"""
  9. self.value = v
  10. self.suit = s
  11.  
  12. def __lt__(self, c2):
  13. if self.value < c2.value:
  14. return True
  15.  
  16. if self.value == c2.value:
  17. if self.suit < c2.suit:
  18. return True
  19. else:
  20. return False
  21.  
  22. return False
  23.  
  24. >>> c1 = Card(4, 1)
  25. >>> c2 = Card(5, 2)
  26. >>> c1 < c2
  27. True
Add Comment
Please, Sign In to add comment