Attributes and Methods
The class body contains the attributes and methods of the class. These are automatically placed in predetermined areas in the class body. **** Attributes **** appear in the upper portion of the body and methods appear in the lower portion.
Declaration
Attributes and methods are declared with an asset_type followed by text. Notice how the method text is placed in the lower portion of the class body even though it is above the attribute text in the code.
Example: Declaring Attributes and Methods
Shorthand
Shorthand allows us to declare attributes and methods without the asset_type. Shorthand attributes are just written as a string on one line. Shorthand methods are the same and end in a set of parentheses.
Note: asset_type will override shorthand. See line 15.
Example: Shorthand Attributes and Methods
Properties
Attributes and methods have four properties. When using the shorthand method the only required property is the text. If shorthand is not used asset_type and text are both required.
asset_state - determines if the asset is abstract or static
visibility - determines the visibility of a method or attribute
text - describes the attribute or method
Asset State
The asset_state property allows you to label attributes and methods as abstract or static. Abstract assets appear in italics. Static assets appear with an underline.
Example: Attributes and Methods Asset States
Visibility
When used, the visibility property is placed directly in front of the text.
- - signifies a private attribute or method
# - signifies a protected attribute or method
~ - signifies a package private attribute or method
+ - signifies a public attribute or method
Example: Attribute and Method Visibility
Text
You can format text with creole syntax for emphasis and markup language for color and emphasis. You can define colors with a standard color name or hex code.
Example: Attribute and Method Text
With All Properties
Example: Attributes and Methods With All Properties
Last updated
Was this helpful?