Created
May 12, 2022 07:51
-
-
Save darioappsilon/b801cfe01fc103b08f4205e363b753b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Dog <- R6Class( | |
| classname = "Dog", | |
| public = list( | |
| initialize = function(name = NA, age = NA, hair_color = NA) { | |
| private$name = name | |
| private$age = age | |
| private$hair_color = hair_color | |
| self$bark() | |
| }, | |
| bark = function() { | |
| cat(private$name, " says Woof!", sep = "") | |
| }, | |
| show = function() { | |
| cat("Dog: \n") | |
| cat("\tName: ", private$name, "\n", sep = "") | |
| cat("\tAge: ", private$age, " or ", private$dog_age(), " in dog years\n", sep = "") | |
| cat("\tHair color: ", private$hair_color, "\n", sep = "") | |
| } | |
| ), | |
| private = list( | |
| name = NULL, | |
| age = NULL, | |
| hair_color = NULL, | |
| dog_age = function() { | |
| return(private$age * 7) | |
| } | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment