# # Gun class # Bryan Clair 2011 # class Gun: """Emulate a six-shooter gun.""" def __init__(self,capacity=6): """Create a gun with given capacity (default is 6)""" self._capacity = capacity self._shots = self._capacity def fire(self): """Shoot a bullet, if the gun has any left.""" if self._shots > 0: print 'Bang!' self._shots -= 1 else: print 'Click.' def reload(self): self._shots = self._capacity