Class is a set of objects with similar features skill combination
Stressed: stand on a different point of view, the classification obtained is not the same
In the real world: we must first have a target, after class
In the program: some have to define a class, call the class to create an object after
Standing on the perspective Luffy College, we are all students
The real world:
Object 1: Ah king
Features: school = 'luffycity', name = 'king Ah', gender = 'female', age = 18
Skills: learn, eat, sleep
Object 2: three guns Lee
Features: school = 'luffycity', name = 'Lee three guns', gender = 'Male', age = 38
Skills: learn, eat, sleep
Object 3: Zhang ferritin
Features: school = 'luffycity', name = 'Zhang ferritin' gender = 'Male', age = 48
Skills: learn, eat, sleep
Summed up the reality of the middle class fly college students:
Similar features: School = 'luffycity'
Similar skills: study, eat, sleep
Program:
Define categories:
ClassLLuffyStudent:
school='luffycity'
def learn(self):
print('is learning')
def eat(self):
print('is eating')
def sleep(self):
print('is sleeping')
After generating objects:
stu1 = LuffyStudent ()
stu2 = LuffyStudent ()
stu3 = LuffyStudent()