The General Nature of an Object
What Is an Object?
Objects in OOP represent real-world entities in a simplified form, allowing programs to manage their states (attributes) and define their behaviour (methods).
States/data (attributes)
These are the characteristics or properties of the object.
Example- For a Person object, attributes might include name, age, and height.
- For a Car object, attributes might include number of wheels, power source, brand.
Actions (methods)
These are functions the object can perform.
Example- For a Person object, methods might include walk, sleep, and talk.
- For a Car object, methods might include go forward, stop, turn.
In programming, attributes are often referred to as fields or properties, while methods are sometimes called functions or procedures.
Tip- When designing objects, think about what data defines the entity and what actions it can perform.
- This helps create a clear and organised structure.
Understanding Objects and Classes
Class
A blueprint for creating objects, defining their data (attributes) and actions (methods).
As we cannot make classes do something, we need a process of