A-level Computing/AQA/Paper 1/Fundamentals of programming/OOP Examples of key elements

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Examples of the four elements of OOP[edit]

Typical Objects can be things that appear on the screen (e.g., pictures, textboxes, etc.) or things are part of the programming (e.g. actors, connections, particles, etc.).

Attributes: Example[edit]

These store information about the object. In the example above we store the fuel and maxSpeed. The attributes are attached to the classes, and if there are several instances (objects) of the classes then each will store its own version of these variables. Note that instead of the usual dim, there is the word private or public, we'll cover that in the encapsulation section.