Select Git revision
for_loop_summation.c
-
Ross Netusil authoredRoss Netusil authored
barnyard.py 1008 B
class Animal:
"""
This base class should not be directly instantiated. All subclasses should have a move() method.
"""
def __init__(self, name):
self.name = name
def make_sound(self):
print(f'{self.name} is staying quiet.')
class Fish(Animal):
def move(self):
print(f'{self.name} is swimming.')
class Footed(Animal):
def move(self):
print(f'{self.name} is walking.')
def make_sound(self):
print('Moo. Bark bark. Meow.')
class Fowl(Animal):
def walk(self):
print(f'\t{self.name} is walking.')
def fly(self):
print(f'\t{self.name} is flying.')
def move(self):
choice = input(f'Should {self.name} move with feet or wings? ')
if choice.lower()[0] == 'f':
self.walk()
elif choice.lower()[0] == 'w':
self.fly()
else:
print(f'\t{self.name} doesn\'t know how to move using {choice}.')
def make_sound(self):
print('Bok bok.')