I am learning more about OOP in Python and I have hit a bit of a road block. Below is my code:
class Player:
bats = 0
hit = 0
freePass = 0
out = 0
defenseError = 0
def __init__(self, name):
self.name = name
Player.hit+=1
Player.freePass+=1
Player.out+=1
Player.defenseError+=1
#--------------------------------
def main():
steve = Player("steve")
steve.hit
steve.hit
steve.hit
#--------------------------------
main()
As you can tell, I have created a class that is supposed to increment a counter every time an instance is called in the main function. For example, 'steve.hit' is called three different times, so the hit counter should increment to 3. I have attempted many different ways of approaching this; but every time I try something, instead of counting the three different calls as such, the program will only count the three calls as one. Thank you for any help you can give me