library(knitr)
knit("2. Inheritance.Rmd")
## 
## 
## processing file: 2. Inheritance.Rmd
## 
  |                                                                                                                         
  |                                                                                                                   |   0%
  |                                                                                                                         
  |.........                                                                                                          |   8%                   
  |                                                                                                                         
  |..................                                                                                                 |  15% (unnamed-chunk-32)
  |                                                                                                                         
  |...........................                                                                                        |  23%                   
  |                                                                                                                         
  |...................................                                                                                |  31% (unnamed-chunk-33)
  |                                                                                                                         
  |............................................                                                                       |  38%                   
  |                                                                                                                         
  |.....................................................                                                              |  46% (unnamed-chunk-34)
  |                                                                                                                         
  |..............................................................                                                     |  54%                   
  |                                                                                                                         
  |.......................................................................                                            |  62% (unnamed-chunk-35)
  |                                                                                                                         
  |................................................................................                                   |  69%                   
  |                                                                                                                         
  |........................................................................................                           |  77% (unnamed-chunk-36)
  |                                                                                                                         
  |.................................................................................................                  |  85%                   
  |                                                                                                                         
  |..........................................................................................................         |  92% (unnamed-chunk-37)
  |                                                                                                                         
  |...................................................................................................................| 100%                   
## output file: 2. Inheritance.md
## [1] "2. Inheritance.md"
Tiger <- R6Class(
  classname = "Tiger",
  inherit = Person,
  public = list(
    weight = NULL,
    set_weight = function(val){
      self$weight <- val
      cat(self$name, " is weight ", val, ".\n", sep = "")
    },
    great = function(){
      cat("Uhm! My name is ", self$name, "!", sep = "")
    }
  )
  
)
#Calling

Tger <- Tiger$new(
  name = "Siri Tiger",
  age = 18,
  desire = "courage"
  
)
## Hello, my name is Siri Tiger.
## age of 18.
## desire of courage.
#Setting a value

Tger$set_weight(360)
## Siri Tiger is weight 360.
#Calling a function

Tger$say_hello()
## Hello, my name is Siri Tiger.
## age of 18.
## desire of courage.