python.SchoolMem

class Rectangle:
    def __init__(self,New_zxx,New_zxy,New_ysx,New_ysy):
        self.zxx=New_zxx
        self.zxy=New_zxy
        self.ysx=New_ysx
        self.ysy=New_ysy
        self.length = self.ysx - self.zxx
        self.width = self.ysy - self.zxy
    def perimeter(self):
        print('周长:{}'.format(2*(self.length+self.width)))
    def area(self):
        print('面积为:{}'.format(self.length*self.width))
 
a = Rectangle(0,0,1,2)
print(a.length)
print(a.width)
a.perimeter()
a.area()
class SchoolMem:
    def __init__(self,name,sex,age):
        self.name=name
        self.sex = sex
        self.age = age
 
    def Alter(self):
        self.name = input('姓名')
        self.sex = input('性别')
        self.age = input('年龄')
    def PrintInfo(self):
        print(self.name)
        print(self.sex)
        print(self.age)
class Student(SchoolMem):
    total = 0
    def __init__(self,name,sex,age,cno,sno):
        super().__init__(name,sex,age)
        self.cno = cno
        self.sno = sno
        Student.total+=1
    def Alter(self):
        self.cno = input('输入学生所属班级:')
        self.sno = input('输入学生学号:')
    def PrintInfo(self):
        super(Student, self).PrintInfo()
        print(self.cno)
        print(self.sno)
 
class Teacher(SchoolMem):
    total = 0
    def __init__(self,name,sex,age,cono,jno):
        super().__init__(name, sex, age)
        self.cono = cono
        self.jno = jno
        Teacher.total +=1
    def Alter(self):
        self.cono = input('输入老师所属学院:')
        self.jno = input('输入老师工号:')
    def PrintInfo(self):
        super(Teacher, self).PrintInfo()
        print(self.cono)
        print(self.jno)
a=Student('张三','男','18',5,1902073564)
a.PrintInfo()
b=Teacher('李四','男','30',2,1351332)
b.PrintInfo()
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 护眼 设计师:闪电赇 返回首页