Files
work/geji.py
T
2026-10-06 19:51:12 +08:00

18 lines
555 B
Python

class Geji: #父类歌姬
def __init__(self, name, color):
self.name = name
self.color = color
def show(self): #父方法
print(f"{self.name} is {self.color}")
class RedGeji(Geji): #红子类
def show(self): # 重写方法
print(f"{self.name} is {self.color},红必秒蓝")
class BlueGeji(Geji): #蓝
def show(self):
print(f"{self.name} is {self.color},蓝必秒红")
teto = RedGeji("teto", "red")
miku = BlueGeji("miku", "blue")
def go(geji):
geji.show()
go(teto)
go(miku)