Python继承9.2 9.3Python从入门到实践

class Dog():
	def __init__(self,name,age):
		self.name = name
		self.age = age
	
	def sit(self):
		print(self.name.title()+"is now sitting")
	def roll_over(self):
		print(self.name.title()+"rolled over")
class Green_Dog(Dog):
	def __init__(self,name,age):
		super().__init__(name,age)	
		self.color = "green"
	def sit(self):
		print(self.name.title()+"green sitting")
		"""my_dog = Dog('ww',6)
your_dog = Dog('lucky',3)
print(my_dog.name.title())
print(my_dog.age)
print(your_dog.name.title())"""
green_dog = Green_Dog('green',2)
print(green_dog.name.title())
print(green_dog.color)
green_dog.sit()