Poker hand in python
I have a poker game assignment and was wondering if I could be pointed into the right direction as to where to start. I have some given code and two empty functions that need to be filled in. I'm not looking for anyone to do my assignment, I just want some direction. Here it goes:
    
First I have a class Card:
    (nothing needs to be done here)
    
    # card.py
    #  defines a minimal class to represent poker cards
    
    class Card:
        '''Represents cards from a poker deck.  The rank is an integer
        between 1 and 13 and the suit is one of 'c','d','h','s'.
        '''
        def __init__(self,rank,suit):
            self.rank = rank
            self.suit = suit
    
        def getRank(self):
            return self.rank
    
        def getSuit(self):
            return self.suit
    
        def BJValue(self):  # Blackjack card value
            if self.rank <= 10:
                return self.rank
            else:
                return 10
    
        def __str__(self):
            s = ''
            if self.rank == 1:
                s += 'Ace'
            elif 2 <= self.rank <= 10:
                s += str(self.rank)
            elif self.rank == 11:
                s += 'Jack'
            elif self.rank == 12:
                s += 'Queen'
            else:
                s += 'King'
    
            s += ' of '
    
            if self.suit == 'c':
                s += 'Clubs'
            elif self.suit == 'd':
                s += 'Diamonds'
            elif self.suit == 'h':
                s += 'Hearts'
            else:
                s += 'Spades'
            return s
    
    
        def __lt__(self,other):
            if self.rank == other.rank:
                return self.suit < other.suit
            elif self.rank == 1:
                return False
            elif other.rank == 1:
                return True
            else:
                return self.rank < other.rank
    
        def __eq__(self,other):
            return self.rank == other.rank and self.suit == other.suit
    
    
    
    
    
Then I have a class Hand where I need to define maxRank(self) and poker_description(self):
    
    
    # poker_hand.py
    #   class to represent a hand occurring in a poker game
    
    from card import Card
    
    class Hand:
        def __init__(self,card_list):
            self.cards = card_list # must have length 5
    
        def maxRank(self):
            # returns a card of maximum rank in self.card_list
            # if more than one card has that rank, returns the
            # card with the highest suit
            # where 'c' < 'd' < 'h' < 's'
            # (which is just the alphabetic order!)
    
            for i in range(5):
                if self.card_list[i] > self.card_list[i+1]:
                    high = self.card_list[i]
                elif self.card_list[i] < self.card_list[i+1]:
                    high = self.card_list[i+1]
                if high < self.card_list[i+2]:
                    high = self.card_list[i+2]
                elif high < self.card_list[i+3]:
                    high = self.card_list[i+3]
                elif high < self.card_list[i+4]:
                    high = self.card_list[i+4]
                return high    
                
            *#I started off with the above if else statements (hopefully I'm on the right track)
            #Am I doing this the right way or do I need to use info from the "Class card"?*
    
        def poker_description(self):
            # returns one of the following strings:
            # 'Royal Flush','Straight Flush','Four of a Kind','Full House',
            # 'Flush', 'Straight', 'Three of a Kind','Two Pair','Pair',
            # 'High Card'
            
            #Needs to fill in some code here:
    
            
        def __str__(self):
            return '\n'.join([str(c) for c in self.cards])
    
    
            
    if __name__ == "__main__":
        L = [Card(5,'d'),Card(11,'d'),Card(7,'d'),Card(2,'d'),Card(12,'d')]
        h = Hand(L)
        print(h)
        L.sort()
        print(h)
        


Poker hand in python
===

I have a poker game assignment and was wondering if I could be pointed into the right direction as to where to start. I have some given code and two empty functions that need to be filled in. I'm not looking for anyone to do my assignment, I just want some direction. Here it goes:
    
First I have a class Card:
    (nothing needs to be done here)
    
    # card.py
    #  defines a minimal class to represent poker cards
    
    class Card:
        '''Represents cards from a poker deck.  The rank is an integer
        between 1 and 13 and the suit is one of 'c','d','h','s'.
        '''
        def __init__(self,rank,suit):
            self.rank = rank
            self.suit = suit
    
        def getRank(self):
            return self.rank
    
        def getSuit(self):
            return self.suit
    
        def BJValue(self):  # Blackjack card value
            if self.rank <= 10:
                return self.rank
            else:
                return 10
    
        def __str__(self):
            s = ''
            if self.rank == 1:
                s += 'Ace'
            elif 2 <= self.rank <= 10:
                s += str(self.rank)
            elif self.rank == 11:
                s += 'Jack'
            elif self.rank == 12:
                s += 'Queen'
            else:
                s += 'King'
    
            s += ' of '
    
            if self.suit == 'c':
                s += 'Clubs'
            elif self.suit == 'd':
                s += 'Diamonds'
            elif self.suit == 'h':
                s += 'Hearts'
            else:
                s += 'Spades'
            return s
    
    
        def __lt__(self,other):
            if self.rank == other.rank:
                return self.suit < other.suit
            elif self.rank == 1:
                return False
            elif other.rank == 1:
                return True
            else:
                return self.rank < other.rank
    
        def __eq__(self,other):
            return self.rank == other.rank and self.suit == other.suit
    
    
    
    
    
Then I have a class Hand where I need to define maxRank(self) and poker_description(self):
    
    
    # poker_hand.py
    #   class to represent a hand occurring in a poker game
    
    from card import Card
    
    class Hand:
        def __init__(self,card_list):
            self.cards = card_list # must have length 5
    
        def maxRank(self):
            # returns a card of maximum rank in self.card_list
            # if more than one card has that rank, returns the
            # card with the highest suit
            # where 'c' < 'd' < 'h' < 's'
            # (which is just the alphabetic order!)
    
            for i in range(5):
                if self.card_list[i] > self.card_list[i+1]:
                    high = self.card_list[i]
                elif self.card_list[i] < self.card_list[i+1]:
                    high = self.card_list[i+1]
                if high < self.card_list[i+2]:
                    high = self.card_list[i+2]
                elif high < self.card_list[i+3]:
                    high = self.card_list[i+3]
                elif high < self.card_list[i+4]:
                    high = self.card_list[i+4]
                return high    
                
            *#I started off with the above if else statements (hopefully I'm on the right track)
            #Am I doing this the right way or do I need to use info from the "Class card"?*
    
        def poker_description(self):
            # returns one of the following strings:
            # 'Royal Flush','Straight Flush','Four of a Kind','Full House',
            # 'Flush', 'Straight', 'Three of a Kind','Two Pair','Pair',
            # 'High Card'
            
            #Needs to fill in some code here:
    
            
        def __str__(self):
            return '\n'.join([str(c) for c in self.cards])
    
    
            
    if __name__ == "__main__":
        L = [Card(5,'d'),Card(11,'d'),Card(7,'d'),Card(2,'d'),Card(12,'d')]
        h = Hand(L)
        print(h)
        L.sort()
        print(h)
        

