Dec-25-2021, 03:15 AM
(This post was last modified: Dec-25-2021, 03:18 AM by CompleteNewb.)
(Dec-25-2021, 02:33 AM)BashBedlam Wrote: I guess I was thinking of something more like this:
class Player : def __init__ (self, hand) self.hand = hand def checkforpair (self) : # look for pair in self.hand return False def checkforstraight (self): # look for straight in self.hand return False def checkforflush (self) : # return True if flush was found in self.hand return False def checkhand (self) : if self.checkforpair () : return 'pair' elif self.checkforstraight () : return 'straight' elif self.checkforflush () : return 'flush'
So for it to work, everything needs to be inside the player class? Problem is I have a lot of functions? Is there a way to put them in a module and call it in my class file? Like ...
import checkhandfunctions class Player : flop = [ ] def __init__ (self, hand) self.hand = handand in my module...
def checkforpair (self) : # look for pair in self.hand return False def checkforstraight (self): # look for straight in self.hand return False def checkforflush (self) : # return True if flush was found in self.hand return False def checkhand (self) : if self.checkforpair () : return 'pair' elif self.checkforstraight () : return 'straight' elif self.checkforflush () : return 'flush'