
# Arup Guha
# 6/16/2025
# Sample Class as an Example for Quiz 1

class card:

    SUITS = ["Clubs", "Diamonds", "Hearts", "Spades"]
    KINDS = ["Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
             "Ten", "Jack", "Queen", "King", "Ace"]

    def __init__(self, suitNo, kindNo):
        self.suit = card.SUITS[suitNo]
        self.kind = card.KINDS[kindNo]
        self.suitNo = suitNo
        self.kindNo = kindNo

    def __str__(self):
        return self.kind + " of " + self.suit

    # Returns true if and only if self is a higher card than other.
    def beat(self, other):

        # Automatically win better suit.
        if self.suitNo > other.suitNo:
            return True

        # Suit tie, but kind is better.
        if self.suitNo == other.suitNo and self.kindNo > other.kindNo:
            return True

        # We don't win!
        return False

    # REturns the next higher card.
    def successor(self):

        # The successor card has the same suit.
        if self.kindNo < len(card.KINDS)-1:
            return card(self.suitNo, self.kindNo+1)

        # Ace but not of spades. So we go to the next suit.
        if self.suitNo != len(card.SUITS) - 1:
            return card(self.suitNo+1, 0)

        # This has no successor.
        return None


# Test the beat function.
c1 = card(2, 3)
c2 = card(2, 4)
c3 = card(3, 1)
c4 = card(2, 4)

print(c1.beat(c2), c1.beat(c3), c1.beat(c4), c2.beat(c3), c2.beat(c4), c3.beat(c4))
print(c2.beat(c1), c3.beat(c1), c4.beat(c1), c3.beat(c2), c4.beat(c2), c4.beat(c3))


# Test the successor function.
for i in range(51):
    c = card(i//13, i%13)
    d = c.successor()
    print(c, d)
