class Toy: #Static # variable and function belongs to Toy class only # variable tocarry to object
head = "circle"
hands = 2
legs = 1
# function won't carry to object
def a():
print("class only function")
def __init__(self,x,y,name):
self.name = name
self.body = x
self.hat = y
def run(self):
print(f"{self.name} is running")
class Barbie(Toy): #Dynamic # Have shell
def __init__(self,x,y,name,hair):
super().__init__(x,y,name)
self.hair = hair
print(f"Barbie: hair {self.hair}")
def jump(self):
print(f"Barbie: {self.name} jump")
# overwrite parent's function with additional function
def run(self):
super().run()
print(f"{self.name} don't like running")
barbie_baby = Barbie('short','white','bb','black')
barbie = Barbie('tall','green','bb-girl','red')
print(barbie_baby.name)
print(barbie.body)
barbie_baby.run()
barbie_baby.jump()
print(barbie.head)
Toy.a()