Getters and Setters may accept more than 1 arguments and have customized logic.
To do that functions acting as getters and setters need to be created.
Output:
Explanation:
lines 3 - 9
)
accepts one parameter - roundUp
.line 25
.
It's function does not accept any arguments. This means that the function
behaviour cannot be dependant on arguments (like roundUp
).Output:
Explanation:
line 33
the age setter (defined at lines 26 - 28
)
is used. It accepts only one parameter.setNames
setter accepts many parameters and can
have a behaviour based on the accepted parameters.