SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!"package:R6" %in% search()) {
  2.   library(R6)
  3. }
  4.  
  5.  
  6. # Class
  7.  
  8.  
  9. Game <- R6Class("Game",
  10.  
  11.     public = list(
  12.  
  13.         # Properties:
  14.  
  15.         a     = 0,
  16.         b     = 0,
  17.         sum   = 0,
  18.  
  19.  
  20.         # Functions:
  21.  
  22.         run = function() {
  23.             part_1()
  24.             part_2()
  25.             part_3()
  26.         },
  27.  
  28.         part_1 = function() {
  29.             self$a = 10
  30.             return(self$a)
  31.         },
  32.  
  33.         part_2 = function() {
  34.             self$b = 20
  35.             return(self$b)
  36.         },
  37.  
  38.         part_3 = function() {
  39.           self$sum = self$a + self$b
  40.           return(self$sum)
  41.         }
  42.  
  43.      )
  44.  
  45. )
  46. # Instantiate an object base on a class.
  47. game <- Game$new()
  48.  
  49. # Run function that runs through all other functions.
  50. game$run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top