Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dog():
- def __init__(self, name, breed):
- self.name = name
- self.breed = breed
- def rollover(self, will_there_be_a_treat):
- if will_there_be_a_treat:
- print(self.name + ' rolled over')
- else:
- print(self.name + ' is begging')
- def sniff(self):
- if self.breed == 'Bloodhound':
- print(self.name + ' found a dead body in your attic')
- else:
- print(self.name + ' started sniffing your cat\'s butt')
- def sleep(self, length):
- time.sleep(length)
- print(self.name + ' slept for ' + str(length) + ' seconds and is now awake')
- def play_dead(self, will_there_be_a_treat):
- if will_there_be_a_treat:
- print(self.name + ' played dead')
- else:
- print(self.name + ' killed you')
- ## Create a dog named Fido
- fido = Dog('Fido', 'Mutt')
- fido.rollover(True)
- # Fido rolled over
- fido.sniff()
- # Fido started sniffing your cat's butt
- fido.sleep(3)
- # Fido slept for 3 seconds and is now awake
- fido.play_dead(False)
- # Fido killed you
- ## Now for Daisy
- daisy = Dog('Daisy', 'Bloodhound')
- daisy.rollover(False)
- # Daisy is begging
- daisy.sniff()
- # Daisy found a dead body in your attic
- daisy.sleep(2)
- # Daisy slept for 2 seconds and is now awake
- daisy.play_dead(True)
- # Daisy played dead
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement