Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dog:
- def __init__(self, name, variation, color, eye=2, tail=1):
- self.name = name
- self.variation = variation
- self.color = color
- self.eye = eye
- self.age = 0
- self.tail = tail
- self.bark()
- def sit(self):
- print(f"{self.name} sedang duduk santuy sambil nge-vape")
- def cry(self):
- print(f"{self.name} : hikz ... >.<")
- def bark(self):
- print(f"Woof Woof ....")
- def sleep(self):
- print(f"{self.name} ngantuk zzzZZZZZ")
- def eat(self):
- print(f"{self.name} lapar... *monch* *monch*")
- def change_color(self, new_color):
- if new_color.lower() == 'white':
- print('Sorry, anjing ga bisa warna putih bos..')
- else:
- self.color = new_color
- print(f'Ubah warna selesai jadi warna {self.color}')
- def increment_age(self):
- self.age += 1
- def change_number_of_tail(self, number):
- self.tail = number
- dog_1 = Dog('Willie', 'Kintamani', 'Blue', eye=3)
- print(dog_1.name)
- dog_1.sit()
- dog_1.cry()
- dog_1.sleep()
- dog_1.eat()
- dog_1.name = 'Tedjo'
- print(dog_1.name)
- dog_1.sit()
- for i in range(5):
- dog_1.increment_age()
- print(dog_1.age)
- dog_1.change_number_of_tail("2")
- print(dog_1.tail)
- print(dog_1.color)
- dog_1.change_color("black")
- print(dog_1.color)
- dog_2 = Dog('Bagus', 'Lokal', 'Brown')
- print(dog_2.name)
- dog_2.sit()
- dog_2.cry()
- dog_2.sleep()
- dog_2.eat()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement