题解 | #多部门的打工人#
多部门的打工人
https://www.nowcoder.com/practice/e704f2c5c30c4aa0b1de9e71bc584fb3
class Nowcoder:
# 初始化方法
def __init__(self,name,id,num) -> None:
self.name=name
self.id=id
self.num=num
# 打印信息
def printInformation(self):
content = "%s's ID is %s, and his or her number of signing in is %s."%(self.name,self.id,self.num)
print(content)
# 创建IT部门类,继承Nowcoder
class IT(Nowcoder):
def __init__(self, name, id, num, language) -> None:
super().__init__(name, id, num)
self.language = language
def printInformation(self):
return super().printInformation(),print(self.language)
# 创建Designer部门类,继承Nowcoder
class Designer(Nowcoder):
def __init__(self, name, id, num, color) -> None:
super().__init__(name, id, num)
self.color=color
def printInformation(self):
return super().printInformation(),print(self.color)
name,id,num,other = input().split()
niuniu = IT(name,id,int(num),other)
niuniu.printInformation()
name,id,num,other = input().split()
niumei = IT(name,id,int(num),other)
niumei.printInformation()
查看12道真题和解析