Last active
August 23, 2021 22:20
-
-
Save gonza7aav/e3c90025a2ae846ef3a4a8ee1c8cd903 to your computer and use it in GitHub Desktop.
A VS Code snippet to create the getters and setters for a variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Encapsulation principle": { | |
"prefix": ["encapsulation", "getter", "setter", "private"], | |
"body": [ | |
"private ${1:type} ${2:variable};", | |
"", | |
"private void ${2/(.*)/set${1:/capitalize}/} (${1:type} _${2:variable}) {", | |
"\tthis.${2:variable} = _${2:variable};", | |
"}", | |
"", | |
"public ${1:type} ${2/(.*)/get${1:/capitalize}/} () {", | |
"\treturn this.${2:variable};", | |
"}" | |
], | |
"description": "Define a variable with its respective setter and getter" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment