class Course:
def __init__(self, cname, period, fee):
self.cname = cname
self.period =period
self.fee = fee
def get_course(self):
print('The course name is %s, period is %s, the fee is %s '%(self.cname,self.period, self.fee))
class Birthday:
def __init__(self, year, month, day):
self.year = year
self.month = month
self.day = day
def get_birthday(self):
print('The birthday is %s %s %s'%(self.year, self.month, self.day))
class People:
country = 'China'
def __init__(self, name, age):
self.name = name
self.age = age
self.courses = []
def tell_info(self):
print('Name is %s, the age is %s'%(self.name, self.age))
class People1(People):
def __init__(self, name, age, sex, hobby):
super().__init__(name, age)
self.sex = sex
self.hobby = hobby
self.courses = []
def tell_info(self):
super().tell_info()
print('the gender is %s, the hobby is %s' % (self.sex, self.hobby))
def show_course_info(self):
print(('%s course info is following'% self.name).center(45,'='))
for course_obj in self.courses:
course_obj.get_course()
p = People1('Raimond', 18, 'male', 'reading')
python = Course('python', '3weeks', '2000')
mysql = Course('mysql', '1weeks', '500')
web = Course('web', '5weeks', '5000')
p.courses.extend([python, mysql,web])
p.show_course_info()
C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe “C:/Users/user/PycharmProjects/hellow python/test.py”
=Raimond course info is following
The course name is python, period is 3weeks, the fee is 2000
The course name is mysql, period is 1weeks, the fee is 500
The course name is web, period is 5weeks, the fee is 5000
Process finished with exit code 0