Sixth week day01 jobs

# Elective system in the project involves a lot of data and functions, require the introduction of object-oriented thinking its highly integrated 
# 1, school data and functional integration
# 2, data and function integration course
# 3, student data and function integration
# 4, lecturer and data integration functionality
# 5, class data and function integration
# ps: students can not write, you can use an ordinary way, first gave written data and functions, then consider object-oriented thinking integration
#
# data section:
# Campus names: such as "old boy Shanghai Campus"
# Campus address: such as "Shanghai Hongqiao"
#
# class name
# class where the campus
#
# students in school
# student's name
# of students age
# student ID
# student sex
#
# course name
# course cycle
# course price
#
the name of the teacher's #
# teacher's age
salary # teachers
grade teacher #
#
#
# functional parts:
the # campuses created, can each Campus create a class
#
# Class Once created, you can create a course for each class
#
# After the students created, students can choose classes
#
# After the teacher has been created, you can score the student

# campus information
class School:
DEF __init __ (Self, campus, campus_address ):
self.campus = campus
self.campus_address = campus_address
self.class_name = []
self.teachers = []
self.students = []
self.course = []

# Create a class
DEF create_class (Self):
class_name = INPUT ( ' Please enter a class name: ') Strip ().
self.class_name.append (class_name)
Print (F' class name:} {class_name ')


school_obj School = ( "old boys Shanghai campus", "Shanghai Hongqiao")
school_obj1 = School ( "old boy campus of Beijing", "Beijing")
school_obj.create_class ()
school_obj1.create_class ()


# Print (school_obj .__ dict__ magic)

# class information
class Class:
DEF the __init __ (Self, name, campus):
self.class_name name =
self.class_campus = campus
self.class_course = []

DEF create_course (Self):
COURSE_NAME = iNPUT ( "Please enter the class name: ') Strip ().
self.class_course.append (COURSE_NAME)
Print (F' class course: COURSE_NAME {} ')


CLASS_OBJ Class = (' PY14 period ', 'old boys Shanghai Campus')
class_obj1 = class ( 'py15 period', 'Beijing campus of old boys')
class_obj.create_course ()
class_obj1.create_course ()


# course information

class course,:
DEF __init __ (Self, name, Cycle,. price) :
name = self.course_name
self.cycle = Cycle
self.price =. price


course_obj = Course, ( 'Python', '. 6 months', '20000')
course_obj1 = Course, ( 'Linux', '. 6 months', '20000' )


# student information
class student:
DEF __init __ (Self, name, Age, Sex, id_card):
self.school = school_obj.campus
self.name = name
self.age = Age
self.sex = Sex
self.id = id_card
school_obj .students.append (name)

# select class
DEF choice_class (Self):
Print ( 'select the class' .center (30, '='))
the while True:
for index, I in the enumerate (school_obj.class_name):
print (f 'Class ID: {index} --- Class Name: {I}')
Choice = INPUT ( 'Enter your choice of the number of classes:'). Strip ()
Choice = int (Choice)
IF Choice Not in Range (len (school_obj.class_name)):
Print ( 'Please enter the correct number of classes')
Continue
student_class = school_obj.class_name [Choice]
Print (F' current student: {school_obj.class_name [choice]} class is: { } student_class')
BREAK


# student. 1
stu_obj student = ( 'Egon', 18 is, 'F', 5,425,025,045)
stu_obj.choice_class ()
# student 2
stu_obj1 student = ( 'Tank', 18 is, 'M', 8888888888)
stu_obj1. choice_class ()
# student. 3
stu_obj2 student = ( 'Alex', 18 is, 'Male ', 6666666666)
stu_obj2.choice_class ()


# Print (stu_obj .__ dict__)
# teachers information
class Teacher:
DEF __init __ (Self, name, Age, salary, Level):
self.name = name
self.age = Age
self.salary salary =
Self. Level = Level
school_obj.teachers.append (name)

# of students scoring
DEF stu_score (Self):
Print ( 'scoring students' .center (30, '='))
the while True:
for index, i in the enumerate (school_obj.students) :
Print (f 'student numbers: {index} --- student name: {i}')
choice = the iNPUT ( 'Please enter the student number of your choice:'). Strip ()
choice = int (choice)
IF choice not in range (len (school_obj.students)) :
print ( 'Please enter a valid student ID')
the Continue
Score the INPUT = ( 'Please enter the fight score:') Strip ().
IF not score.isdigit ():
print ( 'Please enter the correct scores of students')
the Continue
print (f 'teacher: {self.name} to students {school_obj.students [choice]} hit score of: score {}')
BREAK


# teachers 1
teacher_obj = teacher ( 'Tank', 18, 30000, 'Higher people teachers')
teacher_obj.stu_score ()
# teachers 2
teacher_obj1 = teacher ( 'alex', 18, 3000, 'middle-class teacher of the people')
teacher_obj1.stu_score ()
# teachers 3
teacher_obj2 = teacher ( 'Egon', 18, 300, 'low-level people's teachers')
teacher_obj2.stu_score ()

Guess you like

Origin www.cnblogs.com/h1227/p/12654811.html