Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ines
- class Weapon:
- def __init__(self, bullets):
- self.bullets = bullets
- def shoot(self):
- if self.bullets:
- self.bullets -= 1
- return 'shooting...'
- return f"no bullets left"
- def __repr__(self):
- return f"Remaining bullets: {self.bullets}"
- weapon = Weapon(5)
- print(weapon.shoot())
- print(weapon.shoot())
- print(weapon.shoot())
- print(weapon.shoot())
- print(weapon.shoot())
- print(weapon.shoot())
- print(weapon)
Advertisement
Add Comment
Please, Sign In to add comment