Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,14 @@
class Animal:
pass #functions go here...
class Dog(Animal):
pass #functions go here...
class Cat(Animal):
pass #functions go here...
class Lab(Dog):
pass #functions go here...
class Collie(Dog):
pass #functions go here...

View file

@ -0,0 +1,47 @@
import time
class Animal(object):
def __init__(self, birth=None, alive=True):
self.birth = birth if birth else time.time()
self.alive = alive
def age(self):
return time.time() - self.birth
def kill(self):
self.alive = False
class Dog(Animal):
def __init__(self, bones_collected=0, **kwargs):
self.bone_collected = bones_collected
super(Dog, self).__init__(**kwargs)
class Cat(Animal):
max_lives = 9
def __init__(self, lives=max_lives, **kwargs):
self.lives = lives
super(Cat, self).__init__(**kwargs)
def kill(self):
if self.lives>0:
self.lives -= 1
if self.lives == 0:
super(Cat, self).kill()
else:
raise ValueError
return self
class Labrador(Dog):
def __init__(self, guide_dog=False, **kwargs):
self.guide_dog=False
super(Labrador, self).__init__(**kwargs)
class Collie(Dog):
def __init__(self, sheep_dog=False, **kwargs):
self.sheep_dog=False
super(Collie, self).__init__(**kwargs)
lassie = Collie()
felix = Cat()
felix.kill().kill().kill()
mr_winkle = Dog()
buddy = Labrador()
buddy.kill()
print "Felix has",felix.lives, "lives, ","Buddy is %salive!"%("" if buddy.alive else "not ")