Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Item():
- def __init__(self,item_name):
- self.name=item_name
- self.description=None
- self.powers = []
- def set_description(self, item_description):
- self.description = item_description
- def get_description(self):
- return self.description
- def set_name(self, item_name):
- self.name = item_name
- def get_name(self):
- return self.name
- def add_power(self, power):
- self.powers.append(power)
- def get_power(self):
- return self.powers
- def describe(self):
- print( self.description )
- def get_details(self):
- iname=self.name
- print('\n',iname)
- idescr=self.description
- print(idescr)
- for power in self.powers:
- print( "This has " + power + " (power) " )
- if __name__ == "__main__":
- s=Item('Sword')
- s.set_description('shiny metal; I cut clean')
- s.add_power('Kills trolls')
- s.add_power('Opens locked chests')
- s2=Item('Cloak')
- s2.set_description('a shiny goldern cloak')
- s2.add_power('makes you invisible')
- s2.add_power('neutralises Dragons')
- s.get_details()
- s2.get_details()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement