Created
November 13, 2016 08:43
-
-
Save Ratstail91/4cbdbb4a881ce3906e4acf13632e29e9 to your computer and use it in GitHub Desktop.
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 Animal: | |
__name = "" | |
__height = 0 | |
__weight = 0 | |
__sound = "" | |
def __init__(self, name, height, weight, sound): | |
self.__name = name | |
self.__height = height | |
self.__weight = weight | |
self.__sound = sound | |
def SetName(self, name): | |
self.__name = name | |
def GetName(self): | |
return self.__name | |
def SetHeight(self, height): | |
self.__height = height | |
def GetHeight(self): | |
return self.__height | |
def SetWeight(self, weight): | |
self.__weight = weight | |
def GetWeight(self): | |
return self.__weight | |
def SetSound(self, sound): | |
self.__sound = sound | |
def GetSound(self): | |
return self.__sound | |
def GetType(self): | |
return "Animal" | |
def ToString(self): | |
return "{} is {}cm tall and {}kg and says {}.".format(self.__name, self.__height, self.__weight, self.__sound) | |
class Dog(Animal): | |
__owner = "" | |
def __init__(self, name, height, weight, sound, owner): | |
super(Dog, self).__init__(name, height, weight, sound) | |
self.__owner = owner | |
def SetOwner(self, owner): | |
self.__owner = owner | |
def GetOwner(self): | |
return self.__owner | |
def GetType(self): | |
return "Dog" | |
def ToString(self): | |
return "{} is {}cm tall and {}kg and says {} and is owned by {}.".format(self.GetName(), self.GetHeight(), self.GetWeight(), self.GetSound(), self.__owner) | |
cat = Animal("Whiskers", 33, 1.2, "meow") | |
print(cat.ToString()) | |
dog = Dog("Kai", 30, 2, "wolf", "Jordan") | |
print(dog.ToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment