Created
July 1, 2018 14:50
-
-
Save CodePint/387537ac48ff46a84838a5b84800cebf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hand | |
attr_accessor :cards, :highest_hand, :value | |
include Comparable | |
def initialize(cards:, highest_hand:) | |
@cards = cards | |
@highest_hand = highest_hand | |
end | |
def set_value(value) | |
@value = value | |
end | |
def <=>(other) | |
self.value <=> other.value | |
end | |
end | |
my_hand = Hand.new(cards: "TH JH QH KH AH", highest_hand: "royal_flush") | |
other_hand = Hand.new(cards: "TC TD KS KD 3C", highest_hand: "two_pair") | |
my_hand.set_value(10) | |
other_hand.set_value(3) | |
puts my_hand > other_hand | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment