PyBaccarat
visit the ministry of silly walks
|
The Card class represents a single playing card. More...
Public Member Functions | |
def | __init__ (self, new_ordinal, new_suit=None) |
Create a new playing card. More... | |
def | get_rank (self) |
Return the rank of this card. More... | |
def | get_suit (self) |
Return the suit of this card. More... | |
def | get_ordinal (self) |
Return the ordinal value. More... | |
def | __str__ (self) |
Return the string representation for this card. More... | |
def | __eq__ (self, other) |
Returns the result of equals (==) between this Card and other Card. More... | |
def | __ne__ (self, other) |
Returns the result of not equals (!=) between this Card and other Card. More... | |
def | __lt__ (self, other) |
Less than method. More... | |
def | __le__ (self, other) |
Less or equal than method. More... | |
def | __gt__ (self, other) |
Greater than method. More... | |
def | __ge__ (self, other) |
Greater than or equal method. More... | |
def | __hash__ (self) |
Override the default hash behavior (that returns the id of the object). More... | |
def | __init__ (self, new_ordinal, new_suit=None) |
Create a new playing card. More... | |
def | get_rank (self) |
Return the rank of this card. More... | |
def | get_suit (self) |
Return the suit of this card. More... | |
def | get_ordinal (self) |
Return the ordinal value. More... | |
def | __str__ (self) |
Return the string representation for this card. More... | |
def | __eq__ (self, other) |
Returns the result of equals (==) between this Card and other Card. More... | |
def | __ne__ (self, other) |
Returns the result of not equals (!=) between this Card and other Card. More... | |
def | __lt__ (self, other) |
Less than method. More... | |
def | __le__ (self, other) |
Less or equal than method. More... | |
def | __gt__ (self, other) |
Greater than method. More... | |
def | __ge__ (self, other) |
Greater than or equal method. More... | |
def | __hash__ (self) |
Override the default hash behavior (that returns the id of the object). More... | |
Public Attributes | |
face_up | |
The Card class represents a single playing card.
It is immutable. That is, once created this Card can not be changed. This Card is a general purpose playing card that can be use by many different games.
Example usage:
It is immutable. That is, once created this Card can not be changed. This Card is a general purpose playing card that can be use by many different games.
Example usage:
def pybaccarat.playingcards.Card.__init__ | ( | self, | |
new_ordinal, | |||
new_suit = None |
|||
) |
Create a new playing card.
There are 3 syntaxes that can be used to create this new card. First, a single integer in the range 0 to 51. Where each integer maps to a particular rank and suit. The second syntax is to supply a rank and suit. Third, a string naming of the rank and suit.
Example usage:
The first syntax is a single integer value 0 to 51. This would likely be used by a program that wants to create an array of cards quickly. Such as a complete deck of cards. To create a complete deck of cards use the following code.
The second syntax would be the case of creating a single specific playing card. This would likely be a rare useage. But, it is available in case a single card is wanted. The syntax would be 2 arguments: rank and suit. The rank is an integer in the range 1 to 13. The suit is a single string character.
The third syntax is similar to the second, only using the string representation of the Card. This is the same syntax used to write a Card object with the str() method.
self | this object pointer reference |
new_ordinal | integer value 0 to 51 inclusive. If 2 arguements are given for the creation of a card the integer value will be the rank in the range 1 to 13. Or a string representation of the Card value. |
new_suit | Used only when 2 arguments are given for creating a new card. The single string character will represent the suit. Accepted values are 's', 'h', 'd', or 'c'. |
ValueError | If the input parameter is not valid this exception will be raised. |
An example of an exception is:
def pybaccarat.playingcards.Card.__init__ | ( | self, | |
new_ordinal, | |||
new_suit = None |
|||
) |
Create a new playing card.
There are 3 syntaxes that can be used to create this new card. First, a single integer in the range 0 to 51. Where each integer maps to a particular rank and suit. The second syntax is to supply a rank and suit. Third, a string naming of the rank and suit.
Example usage:
The first syntax is a single integer value 0 to 51. This would likely be used by a program that wants to create an array of cards quickly. Such as a complete deck of cards. To create a complete deck of cards use the following code.
The second syntax would be the case of creating a single specific playing card. This would likely be a rare useage. But, it is available in case a single card is wanted. The syntax would be 2 arguments: rank and suit. The rank is an integer in the range 1 to 13. The suit is a single string character.
The third syntax is similar to the second, only using the string representation of the Card. This is the same syntax used to write a Card object with the str() method.
self | this object pointer reference |
new_ordinal | integer value 0 to 51 inclusive. If 2 arguements are given for the creation of a card the integer value will be the rank in the range 1 to 13. Or a string representation of the Card value. |
new_suit | Used only when 2 arguments are given for creating a new card. The single string character will represent the suit. Accepted values are 's', 'h', 'd', or 'c'. |
ValueError | If the input parameter is not valid this exception will be raised. |
An example of an exception is:
def pybaccarat.playingcards.Card.__eq__ | ( | self, | |
other | |||
) |
Returns the result of equals (==) between this Card and other Card.
Overwrites the default object class behavior. The default object class compares instanciated Card's addresses. Thus two cards with the same rank and suit will not be equal. This method will cause two cards of the same rank and suit to be considered equal.
Example usage:
self | this object pointer reference |
other | object A second Card to compare with |
def pybaccarat.playingcards.Card.__eq__ | ( | self, | |
other | |||
) |
Returns the result of equals (==) between this Card and other Card.
Overwrites the default object class behavior. The default object class compares instanciated Card's addresses. Thus two cards with the same rank and suit will not be equal. This method will cause two cards of the same rank and suit to be considered equal.
Example usage:
self | this object pointer reference |
other | object A second Card to compare with |
def pybaccarat.playingcards.Card.__ge__ | ( | self, | |
other | |||
) |
Greater than or equal method.
Greater than or equal does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__ge__ | ( | self, | |
other | |||
) |
Greater than or equal method.
Greater than or equal does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__gt__ | ( | self, | |
other | |||
) |
Greater than method.
Greater than does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__gt__ | ( | self, | |
other | |||
) |
Greater than method.
Greater than does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__hash__ | ( | self | ) |
Override the default hash behavior (that returns the id of the object).
The new hash will be the two saved values that define which card this class represents.
self | this object pointer reference |
def pybaccarat.playingcards.Card.__hash__ | ( | self | ) |
Override the default hash behavior (that returns the id of the object).
The new hash will be the two saved values that define which card this class represents.
self | this object pointer reference |
def pybaccarat.playingcards.Card.__le__ | ( | self, | |
other | |||
) |
Less or equal than method.
Less than or equal does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__le__ | ( | self, | |
other | |||
) |
Less or equal than method.
Less than or equal does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__lt__ | ( | self, | |
other | |||
) |
Less than method.
Less than does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__lt__ | ( | self, | |
other | |||
) |
Less than method.
Less than does not have meaning for a general purpose playing card, so it is disabled.
self | this object pointer reference |
other | object A second Card to compare with |
NotImplmentedError |
def pybaccarat.playingcards.Card.__ne__ | ( | self, | |
other | |||
) |
Returns the result of not equals (!=) between this Card and other Card.
Overwrites the default object class behavior. The default object class compares instanciated Card's addresses. Thus two cards with the same rank and suit will not be equal. I want two cards of the same rank and suit will be equal.
self | this object pointer reference |
other | object A second Card to compare with |
def pybaccarat.playingcards.Card.__ne__ | ( | self, | |
other | |||
) |
Returns the result of not equals (!=) between this Card and other Card.
Overwrites the default object class behavior. The default object class compares instanciated Card's addresses. Thus two cards with the same rank and suit will not be equal. I want two cards of the same rank and suit will be equal.
self | this object pointer reference |
other | object A second Card to compare with |
def pybaccarat.playingcards.Card.__str__ | ( | self | ) |
Return the string representation for this card.
This method overwrites the object class method of this same name.
Example usage:
self | this object pointer reference |
def pybaccarat.playingcards.Card.__str__ | ( | self | ) |
Return the string representation for this card.
This method overwrites the object class method of this same name.
Example usage:
self | this object pointer reference |
def pybaccarat.playingcards.Card.get_ordinal | ( | self | ) |
Return the ordinal value.
The ordinal value is computed as a single integer value for each of the 52 cards.
self | this object pointer reference |
def pybaccarat.playingcards.Card.get_ordinal | ( | self | ) |
Return the ordinal value.
The ordinal value is computed as a single integer value for each of the 52 cards.
self | this object pointer reference |
def pybaccarat.playingcards.Card.get_rank | ( | self | ) |
Return the rank of this card.
self | this object pointer reference |
1 | ace |
2 to 10 | are numbered cards 2 to 10 |
11 | jack |
12 | queen |
13 | king |
def pybaccarat.playingcards.Card.get_rank | ( | self | ) |
Return the rank of this card.
self | this object pointer reference |
1 | ace |
2 to 10 | are numbered cards 2 to 10 |
11 | jack |
12 | queen |
13 | king |
def pybaccarat.playingcards.Card.get_suit | ( | self | ) |
Return the suit of this card.
self | this object pointer reference |
'c' | clubs |
'd' | diamonds |
'h' | hearts |
's' | spades |
def pybaccarat.playingcards.Card.get_suit | ( | self | ) |
Return the suit of this card.
self | this object pointer reference |
'c' | clubs |
'd' | diamonds |
'h' | hearts |
's' | spades |