NOTE: Learners are introduced to the concept of properties in the world of Bug World. To learn more about properties and other concepts, check out the full learning guide for Bug World --> click HERE
Definition: A characteristic of an object.
Example: Properties are the characteristics of an object. In the Car class, there are certain properties, or features, that all cars have, like steering wheels, brakes, and color, but the values of each property can differ between each individual object.
For example, let's say you have black car. Remember, your car is an individual object that can be modified independently from other objects in the same class. You can choose to modify a characteristic of your car, like its color, by painting it red! Your car is still an object in the Car class; you've simply altered a property value of your car that affects how it looks.
If we were creating a program with these two cars in it, these objects would both have a color property as defined by the Car class, but the color property for your car is now "red"; while the property before painting was "black".
Application: Properties are special types of variables that are associated with an object. Properties are assigned to a class when the class is defined, and their values can be modified on individual objects. Modifying properties of an object will make the object different from the main class and any other objects. You can add or delete properties, but all objects will automatically inherit the properties of the main class when they are created.
In Kodable’s Bug World, each tower object has default properties from the class it was created from. Learners unlock the ability to modify objects and change these property values, like strength and speed.
When a learner increases the strength property for one BlueBlaster, this change does not affect ALL towers in the BlueBlaster class; editing the property values on an object only changes that one object.
Why We Use Properties: Properties allow you to change a single object and it will have an isolated effect on your program, independent of other objects. Properties are what make objects different from each other.