python_cardSetup_classes

python_cardSetup_classes - import random class CCard():...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import random class CCard(): "denote a card with rank and suit" def __init__(self, cr=0, cs=''): # rank is one less than face value, i.e. a four of hearts has rank value of 3 # why? for indexing, of course: see the disp_card method self.__rank = cr #0-Ace 1-9 face value . .. 10-Jack 11-Queen 12-King self.__suit = cs #CSDH club spade diamond heart or empty string for blank (no card) def set_rank(self, cr): self.__rank = cr #set the rank of the card 0-12 def set_suit(self, cs): self.__suit = cs #set the suit CSDH def get_rank(self): return self.__rank #returns 0-12 def get_suit(self): return self.__suit #return char one of CSDH #get the value on the face card 2-10 (Jack, Queen, King = 10) Ace = 1 def get_val(self): if self.__suit == "": return 0 if self.__rank < 10: return self.__rank + 1 #if Ace not high, the use "<" return 10 #return Jack, Queen or King #display a card to the string def display(self, string): return string + self.disp_card() def disp_card(self): #return the card display as a string
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2008 for the course CSE 231 taught by Professor Punch during the Fall '07 term at Michigan State University.

Page1 / 3

python_cardSetup_classes - import random class CCard():...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online