مراجعة (Class ) (Object) بشكل سهل وممتع

[python]

:mortar_board: مراجعة اليوم: الـClass والـObject - “تشكيل الأبطال” :man_superhero::woman_superhero:

العربية :saudi_arabia::

هل تخيلت يومًا أنك تمتلك مصنعًا سريًا لتصنيع أبطال خارقين؟ في عالم البرمجة، هذا المصنع يُسمى Class، والأبطال الذين تصنعهم يُسمون Objects.

:factory: Class: “مصنع الأبطال”

  • الـClass هو الخطة الأساسية، التصميم الذي تحدد من خلاله الصفات والقدرات لكل بطل (كائن). إنه الوصفة السحرية التي تُستخدم لصناعة كل أبطالك!
  • مثال:
    class Hero:
        def __init__(self, name, power):
            self.name = name
            self.power = power
    

:man_superhero: Object: “البطل الفعلي”

  • الـObject هو البطل الذي يصنع من الـClass. تخيل أنك صنعت بطلًا خارقًا بناءً على التصميم الذي وضعته. كل Object هو نسخة خاصة وفريدة من الـClass.
  • مثال:
    superman = Hero("Superman", "Flying")
    

الخلاصة:

الـClass هو المخطط الأساسي لصنع الأبطال، والـObject هو البطل الذي يتجسد في الواقع بناءً على هذا المخطط. كلما أردت بطلًا جديدًا، ما عليك إلا أن تستدعي الـClass وتطلق العنان للإبداع!


English :uk::

Ever imagined having a secret factory for creating superheroes? In the world of programming, that factory is called a Class, and the heroes you create are called Objects.

:factory: Class: “The Hero Factory”

  • A class is the blueprint, the master plan that defines the attributes and abilities of each hero (object). It’s the magic recipe used to create all your superheroes!
  • Example:
    class Hero:
        def __init__(self, name, power):
            self.name = name
            self.power = power
    

:man_superhero: Object: “The Actual Hero”

  • The object is the hero made from the class. Imagine you’ve created a superhero based on the blueprint you designed. Each object is a unique, real-world instance of the class.
  • Example:
    superman = Hero("Superman", "Flying")
    

Conclusion:

The class is the master plan for creating heroes, and the object is the hero brought to life based on that plan. Whenever you need a new hero, just call the class and unleash your creativity!


[python]

6 إعجابات