Created
November 30, 2019 08:12
-
-
Save wblxyxolbkhv/d207ef8b12a521e4dc67510ea6160763 to your computer and use it in GitHub Desktop.
Cats cats cats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Cat: | |
| def __init__(self, | |
| name, | |
| color): | |
| self.name = name | |
| self.color = color | |
| self.is_dirty = False | |
| def sleep(self): | |
| print('Cat {} zzzzZZZZ'.format(self.name)) | |
| def eat(self, food): | |
| print('Cat {} eat {}'.format(self.name, food)) | |
| def talk(self): | |
| print('Cat {} say Meow!'.format(self.name)) | |
| def get_color(self): | |
| if self.is_dirty: | |
| print('Cat {} dirty'.format(self.name)) | |
| else: | |
| print('Cat {} {}'.format(self.name, self.color)) | |
| tom = Cat(name='Tom', color='gray') | |
| keks = Cat(name='Keks', color='black') | |
| maria = Cat(name='Maria', color='red') | |
| tom.sleep() | |
| keks.sleep() | |
| maria.sleep() | |
| tom.eat(food='hedgehog') | |
| keks.eat(food='keks') | |
| maria.eat(food='meat') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment