Created
May 12, 2022 08:41
-
-
Save darioappsilon/5fc43f53219bb6e41fd24d087309976c 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
| Animal <- R6Class( | |
| classname = "Animal", | |
| public = list( | |
| initialize = function(name = NA, age = NA, number_of_legs = NA) { | |
| private$name = name | |
| private$age = age | |
| private$number_of_legs = number_of_legs | |
| }, | |
| make_sound = function(sound) { | |
| cat(private$name, " says ", sound, "\n", sep = "") | |
| } | |
| ), | |
| private = list( | |
| name = NULL, | |
| age = NULL, | |
| number_of_legs = NULL | |
| ) | |
| ) | |
| Dog <- R6Class( | |
| classname = "Dog", | |
| inherit = Animal, | |
| public = list( | |
| initialize = function(name = NA, age = NA, number_of_legs = NA, hair_color = NA) { | |
| super$initialize(name, age, number_of_legs) | |
| private$hair_color = hair_color | |
| } | |
| ), | |
| private = list( | |
| hair_color = NULL | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment