Last active
August 29, 2015 14:11
-
-
Save Echocage/86bef2dc3fb3b709a988 to your computer and use it in GitHub Desktop.
This file contains 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 Animal(object): | |
def __init__(self, name, height, weight, sound): | |
self.name = name | |
self.sound = sound | |
self.weight = weight | |
self.height = height | |
def __str__(self): | |
return "{} is {} cm height {} lbs weight and says {}".format(self.name, self.height, self.weight, | |
self.sound) | |
class Dog(Animal): | |
def __init__(self, name, height, weight, sound, owner): | |
self.owner = owner | |
super(Dog, self).__init__(name, height, weight, sound) | |
def __str__(self): | |
return "{} is {} cm height {} lbs weight and says {} . His owner is {}".format(self.name, self.height, | |
self.weight, self.sound, | |
self.owner) | |
cat = Animal("piggy", 10, 40, "Meew") | |
print(cat) | |
print(type(cat).__name__) | |
spot = Dog("spot", 112, 160, "lollu", "Imay") | |
print(spot) | |
print(type(spot).__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment