# Classes and objects
# I understand. , But it's a little hard to use
# Concepts of classes and objects
# class : Of the same kind of transaction Abstract description
# object : Conforming to class description Concrete existence
# Functional encapsulation function -
# Why should we encapsulate it into a function class ? --- whole : Properties and functions ( Behavior )
# First of all Defining classes / Implementation class
# Generating objects
'''
class Class name ( Hump ):
attribute
Method ( function ( function ))
self : It's the object itself
Example method : The first parameter is self
# If you want to create objects at the same time , Customize the properties of the object
# initialization : Magical function __init__
# When you create objects for colleagues , Automatically call .
# Class is optional
'''
# The first instance that is not initialized
# Defining classes
class Dog: # Class name
# kind = None
# kind = ' String ' # Class properties In this way, class attributes are written to death , No matter how many objects , The attributes are all this
kind = ' Dog ' # Class properties All objects are the same
# It's called - Method
def bark(self): # self It's the object itself Class methods use functions
print(' Wang Wang Wang Wang ....')
# eat - Method
def eat(self): # Class methods use functions
print(' Dog food ...')
# run - Method
def run(self): # Class methods use functions
print(' Run ')
# sleep - Method
def sleep(self): # Class methods use functions
print('self In itself :',self) # Object is self
print(' To go to sleep! ')
# Create objects that match the class --- Instantiation
# Object name = Class name () You can create multiple objects
cqg = Dog() # cqg An object is Dog Class
print(' Object itself :',cqg) # Object is self
# Through object . attribute / Method () To get the properties of the missing object , To invoke behavior
cqg.run() # Calling class methods , Instantiation , But no parameters are given
cqg.eat() # Calling class methods , Instantiation
cqg.bark() # Calling class methods , Instantiation
cqg.sleep() # Calling class methods , Instantiation
print(cqg.kind) # The print out is a class attribute
print('**************************************************')
you_jm = Dog() # The second object created It's another object
you_jm.eat()
you_jm.run()
you_jm.bark()
you_jm.sleep()
print(you_jm.kind) # The print out is a class attribute