You have three class attributes: RANKS
, SUITS
and BACK_Name
.
class Card:
# Class Attributes:
RANKS = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
SUITS = ('s', 'c','d','h')
BACK_Name = "DECK/b.gif"
You haven’t defined fileName
as a class attribute so trying to get an attribute named fileName
will raise an AttributeError
indicating that it doesn’t exist.
This is because fileName
, or rather, _fileName
has been defined as an instance attribute via self._filename
:
# Instance Attributes:
def __init__(self, rank, suit):
"""Creates a card with the given rank and suit."""
self.rank = rank
self.suit = suit
self.face="down"
self._fileName="DECK/" + str(rank) + suit[0] + '.gif'
To access this attribute you must first create an instance of the Card
object with with c = Card(rank_value, suit_value)
; then you can access the _filename
via c._filename
.
1
solved Type Object has no attribute